diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index f8d6a51db..1c70a39fc 100644
Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index 990c8bd11..97afd33df 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.06.07 17:34}
+\edef\contextversion{2013.04.09 10:38}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index c8d5fd640..eaa431122 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -3,7 +3,7 @@
%D version=2008.28.10, % 1995.10.10,
%D title=\CONTEXT,
%D subtitle=\CONTEXT\ Format Generation,
-%D author=Hans Hagen, % ɦɑns ɦɑˈχən
+%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
@@ -25,8 +25,8 @@
%D up and the dependencies are more consistent.
\edef\contextformat {\jobname}
-\edef\contextversion{2013.10.15 13:52}
-\edef\contextkind {beta}
+\edef\contextversion{2013.05.28 00:36}
+\edef\contextkind {current}
%D For those who want to use this:
@@ -91,8 +91,6 @@
\loadmarkfile{cldf-ini}
-% \tracecatcodetables
-
% From here on we have \unexpanded being \normalprotected, as we already had
% \unexpanded long before etex came around.
@@ -164,7 +162,7 @@
\loadmarkfile{supp-ran}
\loadmarkfile{supp-mat}
-%loadmarkfile{spac-cha} % obsolete
+\loadmarkfile{spac-cha}
%loadmarkfile{supp-num} % obsolete
\loadmarkfile{typo-ini}
@@ -326,6 +324,19 @@
\loadmarkfile{strc-bkm} % bookmarks
+\loadmarkfile{tabl-com}
+\loadmarkfile{tabl-pln}
+
+\loadmarkfile{tabl-tab} % thrd-tab stripped and merged
+
+\loadmarkfile{tabl-tbl}
+\loadmarkfile{tabl-ntb}
+\loadmarkfile{tabl-nte}
+\loadmarkfile{tabl-ltb}
+\loadmarkfile{tabl-tsp}
+\loadmkvifile{tabl-xtb}
+\loadmarkfile{tabl-mis}
+
\loadmarkfile{java-ini}
\loadmkvifile{scrn-fld}
@@ -351,22 +362,6 @@
\loadmkvifile{font-col}
\loadmkvifile{font-gds}
\loadmkvifile{font-aux}
-\loadmkvifile{font-sel}
-
-\loadmarkfile{typo-tal}
-
-\loadmarkfile{tabl-com}
-\loadmarkfile{tabl-pln}
-
-\loadmarkfile{tabl-tab} % thrd-tab stripped and merged
-
-\loadmarkfile{tabl-tbl}
-\loadmarkfile{tabl-ntb}
-\loadmarkfile{tabl-nte}
-\loadmarkfile{tabl-ltb}
-\loadmarkfile{tabl-tsp}
-\loadmkvifile{tabl-xtb}
-\loadmarkfile{tabl-mis}
\loadmarkfile{typo-lan}
@@ -389,8 +384,7 @@
\loadmarkfile{typo-dig}
\loadmarkfile{typo-rep}
\loadmkvifile{typo-txt}
-\loadmarkfile{typo-drp}
-\loadmarkfile{typo-fln}
+\loadmarkfile{typo-par}
\loadmkvifile{type-ini}
\loadmarkfile{type-set}
@@ -409,7 +403,6 @@
\loadmarkfile{meta-fun}
\loadmarkfile{meta-pag}
\loadmarkfile{meta-grd}
-\loadmarkfile{meta-fnt}
\loadmarkfile{page-mrk} % depends on mp
@@ -427,7 +420,7 @@
\loadmarkfile{math-ini}
\loadmarkfile{math-pln}
\loadmarkfile{math-for}
-\loadmarkfile{math-def} % also saves some meanings
+\loadmarkfile{math-def}
\loadmarkfile{math-ali}
%loadmarkfile{math-arr}
\loadmkvifile{math-stc}
@@ -437,8 +430,6 @@
\loadmarkfile{math-int}
\loadmarkfile{math-del}
\loadmarkfile{math-fen}
-\loadmkvifile{math-acc}
-\loadmkvifile{math-rad}
\loadmarkfile{math-inl}
\loadmarkfile{math-dis}
%loadmarkfile{math-lan}
diff --git a/tex/context/base/context.tmp b/tex/context/base/context.tmp
new file mode 100644
index 000000000..7976b4641
--- /dev/null
+++ b/tex/context/base/context.tmp
@@ -0,0 +1,513 @@
+%D \module
+%D [ file=context,
+%D version=2008.28.10, % 1995.10.10,
+%D title=\CONTEXT,
+%D subtitle=\CONTEXT\ 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 \catcode`\#=6
+
+%D From the next string (which is set by the script that assembles the
+%D distribution) later on we will calculate a number that can be used
+%D by use modules to identify the feature level. Starting with version
+%D 2004.8.30 the low level interface is english. Watch out and adapt
+%D 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
+%D up and the dependencies are more consistent.
+
+\edef\contextformat {\jobname}
+\edef\contextversion{2013.05.28 00:34}
+\edef\contextkind {beta}
+
+%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\loadcorefile#1{\normalinput#1\relax}
+\def\loadmarkfile#1{\normalinput#1.\mksuffix\relax}
+\def\loadmkiifile#1{}
+\def\loadmkivfile#1{\normalinput#1.mkiv\relax}
+\def\loadmkvifile#1{\normalinput#1.mkvi\relax}
+
+%D First we load the system modules. These implement a lot of
+%D manipulation macros. We start with setting up some basic \TEX\
+%D machinery.
+
+\loadmarkfile{syst-ini}
+
+%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 We just quit if new functionality is expected.
+
+\ifnum\luatexversion<70 % also change message
+ \writestatus{!!!!}{Your luatex binary is too old, you need at least version 0.70!}
+ \expandafter\end
+\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{catc-ini}
+\loadmarkfile{catc-act}
+\loadmarkfile{catc-def}
+\loadmarkfile{catc-ctx}
+\loadmarkfile{catc-sym}
+
+\loadmarkfile{cldf-ini}
+
+% From here on we have \unexpanded being \normalprotected, as we already had
+% \unexpanded long before etex came around.
+
+\loadmarkfile{syst-aux}
+\loadmarkfile{syst-lua}
+\loadmarkfile{syst-con}
+
+\loadmarkfile{syst-fnt}
+\loadmarkfile{syst-rtp}
+
+\loadmkvifile{file-ini}
+\loadmkvifile{file-res}
+\loadmkvifile{file-lib}
+
+\loadmarkfile{supp-dir}
+
+\loadmarkfile{char-ini}
+\loadmarkfile{char-utf}
+\loadmarkfile{char-act}
+
+\loadmarkfile{mult-ini}
+\loadmarkfile{mult-sys}
+\loadmarkfile{mult-aux}
+\loadmarkfile{mult-def}
+\loadmarkfile{mult-chk}
+%loadmarkfile{mult-aux} % moved up
+\loadmkvifile{mult-dim}
+
+\loadmarkfile{cldf-int} % interface
+
+\loadmarkfile{luat-ini}
+
+\loadmarkfile{toks-ini}
+
+\loadmarkfile{attr-ini}
+
+\loadmarkfile{core-ini}
+\loadmarkfile{core-env}
+
+\loadmarkfile{layo-ini}
+
+\loadmarkfile{node-ini}
+
+\loadmarkfile{cldf-bas} % basics / depends on nodes
+
+\loadmarkfile{node-fin}
+\loadmarkfile{node-mig}
+\loadmarkfile{typo-bld} % par builders
+%loadmarkfile{node-pag}
+
+\loadmarkfile{back-ini}
+
+\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{trac-ctx} % maybe move up
+
+%loadmarkfile{blob-ini} % not to be used, we only use a helper
+
+\loadmarkfile{supp-box}
+
+%loadmarkfile{supp-vis} % replaced by trac-vis
+%loadmarkfile{supp-fun} % mostly replaced
+
+\loadmarkfile{supp-ran}
+\loadmarkfile{supp-mat}
+\loadmarkfile{spac-cha}
+%loadmarkfile{supp-num} % obsolete
+
+\loadmarkfile{typo-ini}
+
+\loadmkvifile{file-syn}
+\loadmkvifile{file-mod}
+
+\loadmarkfile{core-con}
+
+\loadmarkfile{cont-fil}
+
+\loadmarkfile{regi-ini}
+\loadmarkfile{enco-ini}
+\loadmarkfile{hand-ini}
+
+\loadmarkfile{lang-ini}
+\loadmarkfile{lang-lab}
+
+\loadmarkfile{unic-ini}
+
+\loadmarkfile{core-uti}
+\loadmarkfile{core-two}
+\loadmarkfile{core-dat}
+
+\loadmarkfile{colo-ini}
+\loadmarkfile{colo-grp} % optional
+\loadmarkfile{colo-ext}
+
+\loadmarkfile{node-bck} % overloads anch-pgr (experimental and undocumented)
+
+\loadmarkfile{pack-cut} % leftovers from trac-vis
+
+\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}
+\loadmarkfile{pack-rul}
+\loadmarkfile{pack-mrl}
+\loadmkvifile{pack-bck}
+\loadmarkfile{pack-fen}
+
+\loadmarkfile{lxml-ini}
+\loadmarkfile{lxml-sor}
+
+\loadmkvifile{typo-prc}
+
+\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-ali}
+\loadmarkfile{spac-hor}
+\loadmarkfile{spac-flr}
+\loadmarkfile{spac-ver}
+\loadmarkfile{spac-lin}
+\loadmarkfile{spac-pag}
+\loadmarkfile{spac-par}
+%loadmarkfile{spac-adj} % no longer needed
+\loadmarkfile{spac-def}
+\loadmarkfile{spac-grd}
+
+\loadmarkfile{anch-pos}
+
+\loadmkvifile{scrn-ini}
+\loadmkvifile{scrn-ref}
+
+\loadmarkfile{pack-obj}
+
+\loadmkvifile{strc-itm}
+
+\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-grd}
+\loadmarkfile{page-flt}
+\loadmarkfile{page-bck}
+\loadmarkfile{page-not}
+\loadmarkfile{page-one}
+\loadmarkfile{page-lay}
+\loadmkvifile{page-box}
+\loadmkvifile{page-txt}
+\loadmarkfile{page-sid} % when
+
+\loadmkvifile{strc-flt}
+
+\loadmarkfile{page-pst}
+\loadmkvifile{page-mbk}
+\loadmarkfile{page-mul} % partly overloaded
+\loadmarkfile{page-mix} % new
+\loadmarkfile{page-set}
+\loadmarkfile{pack-lyr}
+\loadmarkfile{pack-pos}
+\loadmkvifile{page-mak}
+
+\loadmarkfile{page-lin}
+\loadmarkfile{page-par}
+\loadmarkfile{typo-pag}
+\loadmarkfile{typo-mar}
+\loadmarkfile{typo-itm}
+
+\loadmarkfile{buff-ini}
+\loadmarkfile{buff-ver}
+\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{tabl-com}
+\loadmarkfile{tabl-pln}
+
+\loadmarkfile{tabl-tab} % thrd-tab stripped and merged
+
+\loadmarkfile{tabl-tbl}
+\loadmarkfile{tabl-ntb}
+\loadmarkfile{tabl-nte}
+\loadmarkfile{tabl-ltb}
+\loadmarkfile{tabl-tsp}
+\loadmkvifile{tabl-xtb}
+\loadmarkfile{tabl-mis}
+
+\loadmarkfile{java-ini}
+
+\loadmkvifile{scrn-fld}
+\loadmkvifile{scrn-hlp}
+
+\loadmarkfile{char-enc} % will move up
+
+\loadmkvifile{font-lib} % way too late
+\loadmkvifile{font-fil}
+\loadmkvifile{font-var}
+\loadmkvifile{font-fea}
+\loadmkvifile{font-mat}
+\loadmkvifile{font-ini}
+\loadmkvifile{font-sym}
+\loadmkvifile{font-sty}
+\loadmkvifile{font-set}
+\loadmkvifile{font-emp}
+\loadmarkfile{font-pre}
+\loadmarkfile{font-unk}
+\loadmarkfile{font-tra}
+\loadmarkfile{font-chk}
+\loadmarkfile{font-uni}
+\loadmkvifile{font-col}
+\loadmkvifile{font-gds}
+\loadmkvifile{font-aux}
+
+\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-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-par}
+
+\loadmkvifile{type-ini}
+\loadmarkfile{type-set}
+
+\loadmarkfile{scrp-ini}
+
+\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}
+
+\loadmarkfile{meta-ini}
+\loadmarkfile{meta-tex}
+\loadmarkfile{meta-fun}
+\loadmarkfile{meta-pag}
+\loadmarkfile{meta-grd}
+
+\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}
+\loadmarkfile{math-pln}
+\loadmarkfile{math-for}
+\loadmarkfile{math-def}
+\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}
+\loadmarkfile{math-inl}
+\loadmarkfile{math-dis}
+%loadmarkfile{math-lan}
+
+\loadmarkfile{phys-dim}
+
+\loadmarkfile{strc-mat}
+
+\loadmarkfile{chem-ini}
+\loadmarkfile{chem-str}
+
+\loadmarkfile{typo-scr}
+
+\loadmarkfile{node-rul}
+\loadmkvifile{font-sol} % font solutions
+
+\loadmkvifile{strc-not}
+\loadmkvifile{strc-lnt}
+
+\loadmarkfile{pack-com}
+\loadmarkfile{typo-del}
+
+\loadmarkfile{grph-trf}
+\loadmarkfile{grph-inc}
+\loadmarkfile{grph-fig}
+\loadmarkfile{grph-raw}
+
+\loadmarkfile{pack-box}
+\loadmarkfile{pack-bar}
+\loadmarkfile{page-app}
+\loadmarkfile{meta-fig}
+
+\loadmarkfile{lang-spa} % will become obsolete
+
+\loadmarkfile{bibl-bib}
+\loadmarkfile{bibl-tra}
+
+%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)
+
+\loadmarkfile{back-pdf} % actually, this one should load the next three using document.arguments.backend
+\loadmarkfile{mlib-pdf}
+\loadmarkfile{mlib-pps}
+\loadmarkfile{meta-pdf}
+\loadmarkfile{grph-epd}
+
+\loadmarkfile{back-exp}
+
+\setupcurrentlanguage[\defaultlanguagetag]
+
+\prependtoks
+ \ctxlua{statistics.starttiming(statistics)}%
+\to \everyjob
+
+\appendtoks
+ \ctxlua{statistics.stoptiming(statistics)}%
+\to \everyjob
+
+\appendtoks
+ \ctxlua{statistics.savefmtstatus("\jobname","\contextversion","context.mkiv","\contextkind")}% can become automatic
+\to \everydump
+
+\errorstopmode \dump \endinput
diff --git a/tex/context/base/core-con.lua b/tex/context/base/core-con.lua
index 315a34f39..cb284b9a7 100644
--- a/tex/context/base/core-con.lua
+++ b/tex/context/base/core-con.lua
@@ -216,14 +216,27 @@ function commands.Character (n) context(chr (n,upper_offset)) end
function commands.characters(n) context(chrs(n,lower_offset)) end
function commands.Characters(n) context(chrs(n,upper_offset)) end
-local weekday = os.weekday -- moved to l-os
-local isleapyear = os.isleapyear -- moved to l-os
-local nofdays = os.nofdays -- moved to l-os
+local days = {
+ [false] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ [true] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+}
+
+local function weekday(day,month,year)
+ return date("%w",time{year=year,month=month,day=day}) + 1
+end
+
+local function isleapyear(year)
+ return (year % 400 == 0) or ((year % 100 ~= 0) and (year % 4 == 0))
+end
local function leapyear(year)
return isleapyear(year) and 1 or 0
end
+local function nofdays(year,month)
+ return days[isleapyear(year)][month]
+end
+
local function textime()
return tonumber(date("%H")) * 60 + tonumber(date("%M"))
end
@@ -241,7 +254,7 @@ converters.nofdays = nofdays
converters.textime = textime
function commands.weekday (day,month,year) context(weekday (day,month,year)) end
-function commands.leapyear(year) context(leapyear(year)) end -- rather useless, only for ifcase
+function commands.leapyear(year) context(leapyear(year)) end -- rather useless
function commands.nofdays (year,month) context(nofdays (year,month)) end
function commands.year () context(date("%Y")) end
diff --git a/tex/context/base/core-con.mkiv b/tex/context/base/core-con.mkiv
index 375d77072..7febdcf39 100644
--- a/tex/context/base/core-con.mkiv
+++ b/tex/context/base/core-con.mkiv
@@ -15,8 +15,6 @@
\registerctxluafile{core-con}{1.001}
-% todo: iso date ranges (from/to)
-
\unprotect
\ifdefined\currentlanguage \else \let\currentlanguage\empty \fi
@@ -99,9 +97,6 @@
\def\koreannumeralsp #1{\ctxcommand{alphabetic(\number#1,"korean-parent")}}
\def\koreannumeralsc #1{\ctxcommand{alphabetic(\number#1,"korean-circle")}}
-\let\koreanparentnumerals\koreannumeralsp
-\let\koreancirclenumerals\koreannumeralsc
-
\def\chinesenumerals #1{\ctxcommand{chinesenumerals (\number#1)}}
\def\chinesecapnumerals#1{\ctxcommand{chinesecapnumerals(\number#1,"cap")}}
\def\chineseallnumerals#1{\ctxcommand{chineseallnumerals(\number#1,"all")}}
diff --git a/tex/context/base/core-dat.lua b/tex/context/base/core-dat.lua
index 242d362d0..826d3a675 100644
--- a/tex/context/base/core-dat.lua
+++ b/tex/context/base/core-dat.lua
@@ -21,17 +21,13 @@ local trace_pagestates = false trackers.register("job.pagestates", function(v)
local report_dataset = logs.reporter("dataset")
local report_pagestate = logs.reporter("pagestate")
-local allocate = utilities.storage.allocate
+local allocate = utilities.storage.allocate
local settings_to_hash = utilities.parsers.settings_to_hash
+local texcount = tex.count
+local formatters = string.formatters
+local v_yes = interfaces.variables.yes
-local texgetcount = tex.getcount
-local texsetcount = tex.setcount
-
-local formatters = string.formatters
-
-local v_yes = interfaces.variables.yes
-
-local new_latelua = nodes.pool.latelua
+local new_latelua = nodes.pool.latelua
local collected = allocate()
local tobesaved = allocate()
@@ -90,7 +86,7 @@ local function setdata(settings)
set.index = index
data.index = index
data.order = index
- data.realpage = texgetcount("realpageno")
+ data.realpage = texcount.realpageno
if trace_datasets then
report_dataset("action %a, name %a, tag %a, index %a","assign delayed",name,tag,index)
end
@@ -105,7 +101,7 @@ datasets.setdata = setdata
function datasets.extend(name,tag)
local set = sets[name]
local order = set.order + 1
- local realpage = texgetcount("realpageno")
+ local realpage = texcount.realpageno
set.order = order
local t = tobesaved[name][tag]
t.realpage = realpage
@@ -211,7 +207,7 @@ local function setstate(settings)
else
tag = tonumber(tag) or tag -- autonumber saves keys
end
- local realpage = texgetcount("realpageno")
+ local realpage = texcount.realpageno
local data = realpage
list[tag] = data
if trace_pagestates then
@@ -223,7 +219,7 @@ end
pagestates.setstate = setstate
function pagestates.extend(name,tag)
- local realpage = texgetcount("realpageno")
+ local realpage = texcount.realpageno
if trace_pagestates then
report_pagestate("action %a, name %a, tag %a, preset %a","synchronize",name,tag,realpage)
end
@@ -265,5 +261,9 @@ end
function commands.setpagestaterealpageno(name,tag)
local t = collected[name]
t = t and (t[tag] or t[tonumber(tag)])
- texsetcount("realpagestateno",t or texgetcount("realpageno"))
+ if t then
+ texcount.realpagestateno = t
+ else
+ texcount.realpagestateno = texcount.realpageno
+ end
end
diff --git a/tex/context/base/core-def.mkiv b/tex/context/base/core-def.mkiv
index 99bed6d34..dc2a30f4e 100644
--- a/tex/context/base/core-def.mkiv
+++ b/tex/context/base/core-def.mkiv
@@ -45,8 +45,6 @@
\flushpostponednodedata
\typo_delimited_repeat
\insertparagraphintro
- \typo_initial_handle
- \typo_firstline_handle
\to \everypar
\appendtoks
@@ -95,26 +93,23 @@
\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
+ \loadsystemfiles
+ % \loadoptionfile % obsolete, but nice to keep as reference of when/how
\job_options_get_commandline % expands some commands
\job_options_get_ctxfile % might expand some commands
\job_options_set_filenames
\font_preloads_at_every_job
\settopskip % brrr
\initializemainlanguage
+ \initializexmlprocessing % is this still needed?
\initializepagebackgrounds
\initializepagecounters
+ % \directsetup{*runtime:options}% % obsolete as the option file is replaced by a more direct mechanism
+ % \directsetup{*runtime:modules}% % obsolete as the option file is replaced by a more direct mechanism
\job_options_set_modes
\job_options_set_modules
\job_options_set_environments
diff --git a/tex/context/base/core-env.lua b/tex/context/base/core-env.lua
index a4d1fdd92..025192d4b 100644
--- a/tex/context/base/core-env.lua
+++ b/tex/context/base/core-env.lua
@@ -15,14 +15,12 @@ local P, C, S, Cc, lpegmatch, patterns = lpeg.P, lpeg.C, lpeg.S, lpeg.Cc, lpeg.m
local csname_id = token.csname_id
local create = token.create
-local texgetcount = tex.getcount
+local texcount = tex.count
local texsetcount = tex.setcount
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
-local context = context
-
local undefined = csname_id("*undefined*crap*")
local iftrue = create("iftrue")[2] -- inefficient hack
@@ -44,8 +42,8 @@ setmetatableindex(tex.modes, function(t,k)
if csname_id(n) == undefined then
return false
else
- modes[k] = function() return texgetcount(n) >= 1 end
- return texgetcount(n) >= 1
+ modes[k] = function() return texcount[n] >= 1 end
+ return texcount[n] >= 1
end
end
end)
@@ -59,18 +57,18 @@ setmetatableindex(tex.systemmodes, function(t,k)
if csname_id(n) == undefined then
return false
else
- systemmodes[k] = function() return texgetcount(n) >= 1 end
- return texgetcount(n) >= 1
+ systemmodes[k] = function() return texcount[n] >= 1 end
+ return texcount[n] >= 1
end
end
end)
setmetatableindex(tex.constants, function(t,k)
- return csname_id(k) ~= undefined and texgetcount(k) or 0
+ return csname_id(k) ~= undefined and texcount[k] or 0
end)
setmetatableindex(tex.conditionals, function(t,k) -- 0 == true
- return csname_id(k) ~= undefined and texgetcount(k) == 0
+ return csname_id(k) ~= undefined and texcount[k] == 0
end)
setmetatableindex(tex.ifs, function(t,k)
@@ -86,7 +84,7 @@ end)
-- if glob then
-- texsetcount("global",name,0)
-- else
--- texsetcount(name,0)
+-- texcount[name] = 0
-- end
-- end
--
@@ -94,7 +92,7 @@ end)
-- if glob then
-- texsetcount("global",name,1)
-- else
--- texsetcount(name,1)
+-- texcount[name] = 1
-- end
-- end
diff --git a/tex/context/base/core-fil.mkii b/tex/context/base/core-fil.mkii
index 16daf7bf6..6b0d8caf5 100644
--- a/tex/context/base/core-fil.mkii
+++ b/tex/context/base/core-fil.mkii
@@ -348,10 +348,6 @@
\setupexternalresources
[url=]
-%D Goodie:
-
-\unexpanded\def\continueifinputfile#1{\doifnotfile{#1}{\endinput}}
-
%D This module will be perfected / changed / weeded.
\protect \endinput
diff --git a/tex/context/base/core-uti.lua b/tex/context/base/core-uti.lua
index cbbdeff23..96ccdca48 100644
--- a/tex/context/base/core-uti.lua
+++ b/tex/context/base/core-uti.lua
@@ -20,6 +20,7 @@ saves much runtime but at the cost of more memory usage.
local format, match = string.format, string.match
local next, type, tostring = next, type, tostring
local concat = table.concat
+local texcount = tex.count
local definetable = utilities.tables.definetable
local accesstable = utilities.tables.accesstable
@@ -29,8 +30,6 @@ local packers = utilities.packers
local allocate = utilities.storage.allocate
local mark = utilities.storage.mark
-local texgetcount = tex.getcount
-
local report_passes = logs.reporter("job","passes")
job = job or { }
@@ -96,8 +95,6 @@ job.register('job.variables.checksums', checksums)
local rmethod, rvalue
-local setxvalue = context.setxvalue
-
local function initializer()
tobesaved = jobvariables.tobesaved
collected = jobvariables.collected
@@ -113,7 +110,7 @@ local function initializer()
end
tobesaved.randomseed = rvalue
for cs, value in next, collected do
- setxvalue(cs,value)
+ context.setxvalue(cs,value)
end
end
@@ -141,7 +138,7 @@ local jobpacker = packers.new(packlist,job.packversion) -- jump number when chan
job.pack = true
-- job.pack = false
-directives.register("job.pack",function(v) job.pack = v end)
+directives.register("job.pack",function(v) pack = v end)
local _save_, _load_, _others_ = { }, { }, { } -- registers timing
@@ -150,7 +147,7 @@ function job.save(filename) -- we could return a table but it can get pretty lar
local f = io.open(filename,'w')
if f then
f:write("local utilitydata = { }\n\n")
- f:write(serialize(comment,"utilitydata.comment",true),"\n\n")
+ f:write(serialize(comment,"utilitydata.comment",true,true),"\n\n")
for l=1,#savelist do
local list = savelist[l]
local target = format("utilitydata.%s",list[1])
@@ -163,11 +160,11 @@ function job.save(filename) -- we could return a table but it can get pretty lar
packers.pack(data,jobpacker,true)
end
local definer, name = definetable(target,true,true) -- no first and no last
- f:write(definer,"\n\n",serialize(data,name,true),"\n\n")
+ f:write(definer,"\n\n",serialize(data,name,true,true),"\n\n")
end
if job.pack then
packers.strip(jobpacker)
- f:write(serialize(jobpacker,"utilitydata.job.packed",true),"\n\n")
+ f:write(serialize(jobpacker,"utilitydata.job.packed",true,true),"\n\n")
end
f:write("return utilitydata")
f:close()
@@ -265,7 +262,7 @@ end)
statistics.register("callbacks", function()
local total, indirect = status.callbacks or 0, status.indirect_callbacks or 0
- local pages = texgetcount('realpageno') - 1
+ local pages = texcount['realpageno'] - 1
if pages > 1 then
return format("direct: %s, indirect: %s, total: %s (%i per page)", total-indirect, indirect, total, total/pages)
else
@@ -279,30 +276,17 @@ statistics.register("randomizer", function()
end
end)
-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
- local shipped = texgetcount('nofshipouts')
- local pages = texgetcount('realpageno')
+ local shipped = texcount['nofshipouts']
+ local pages = texcount['realpageno']
if pages > shipped then
pages = shipped
end
if shipped > 0 or pages > 0 then
local persecond = shipped / runtime
if pages == 0 then pages = shipped end
-if jit then
-local saved = watts_per_core * runtime * kg_per_watt_per_second / speedup_by_other_engine
-local saved = used_wood_factor * runtime
--- return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second, %f kg tree saved by using luajittex",runtime,pages,shipped,persecond,saved)
- return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second, %f g tree saved by using luajittex",runtime,pages,shipped,persecond,saved*1000)
-else
return format("%s seconds, %i processed pages, %i shipped pages, %.3f pages/second",runtime,pages,shipped,persecond)
-end
else
return format("%s seconds",runtime)
end
diff --git a/tex/context/base/data-exp.lua b/tex/context/base/data-exp.lua
index c67e97bb1..8a2fd0320 100644
--- a/tex/context/base/data-exp.lua
+++ b/tex/context/base/data-exp.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['data-exp'] = {
local format, find, gmatch, lower, char, sub = string.format, string.find, string.gmatch, string.lower, string.char, string.sub
local concat, sort = table.concat, table.sort
local lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
-local Ct, Cs, Cc, Carg, P, C, S = lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.Carg, lpeg.P, lpeg.C, lpeg.S
+local Ct, Cs, Cc, P, C, S = lpeg.Ct, lpeg.Cs, lpeg.Cc, lpeg.P, lpeg.C, lpeg.S
local type, next = type, next
local ostype = os.type
@@ -26,21 +26,21 @@ local resolvers = resolvers
-- all, when working on the main resolver code, I don't want to scroll
-- past this every time. See data-obs.lua for the gsub variant.
--- local function f_first(a,b)
--- local t, n = { }, 0
--- for s in gmatch(b,"[^,]+") do
--- n = n + 1 ; t[n] = a .. s
--- end
--- return concat(t,",")
--- end
---
--- local function f_second(a,b)
--- local t, n = { }, 0
--- for s in gmatch(a,"[^,]+") do
--- n = n + 1 ; t[n] = s .. b
--- end
--- return concat(t,",")
--- end
+local function f_first(a,b)
+ local t, n = { }, 0
+ for s in gmatch(b,"[^,]+") do
+ n = n + 1 ; t[n] = a .. s
+ end
+ return concat(t,",")
+end
+
+local function f_second(a,b)
+ local t, n = { }, 0
+ for s in gmatch(a,"[^,]+") do
+ n = n + 1 ; t[n] = s .. b
+ end
+ return concat(t,",")
+end
-- kpsewhich --expand-braces '{a,b}{c,d}'
-- ac:bc:ad:bd
@@ -69,21 +69,6 @@ local function f_both(a,b)
return concat(t,",")
end
-local comma = P(",")
-local nocomma = (1-comma)^1
-local docomma = comma^1/","
-local before = Cs((nocomma * Carg(1) + docomma)^0)
-local after = Cs((Carg(1) * nocomma + docomma)^0)
-local both = Cs(((C(nocomma) * Carg(1))/function(a,b) return lpegmatch(before,b,1,a) end + docomma)^0)
-
-local function f_first (a,b) return lpegmatch(after, b,1,a) end
-local function f_second(a,b) return lpegmatch(before,a,1,b) end
-local function f_both (a,b) return lpegmatch(both, b,1,a) end
-
--- print(f_first ("a", "x,y,z"))
--- print(f_second("a,b,c","x"))
--- print(f_both ("a,b,c","x,y,z"))
-
local left = P("{")
local right = P("}")
local var = P((1 - S("{}" ))^0)
diff --git a/tex/context/base/data-met.lua b/tex/context/base/data-met.lua
index ee9de3fd9..96da70bfd 100644
--- a/tex/context/base/data-met.lua
+++ b/tex/context/base/data-met.lua
@@ -36,7 +36,7 @@ local function splitmethod(filename) -- todo: filetype in specification
end
filename = file.collapsepath(filename,".") -- hm, we should keep ./ in some cases
- -- filename = gsub(filename,"^%./",getcurrentdir().."/") -- we will merge dir.expandname and collapse some day
+-- filename = gsub(filename,"^%./",getcurrentdir().."/") -- we will merge dir.expandname and collapse some day
if not find(filename,"://") then
return { scheme = "file", path = filename, original = filename, filename = filename }
@@ -49,16 +49,6 @@ local function splitmethod(filename) -- todo: filetype in specification
end
end
--- local function splitmethod(filename) -- todo: filetype in specification
--- if not filename then
--- return { scheme = "unknown", original = filename }
--- end
--- if type(filename) == "table" then
--- return filename -- already split
--- end
--- return url.hashed(filename)
--- end
-
resolvers.splitmethod = splitmethod -- bad name but ok
-- the second argument is always analyzed (saves time later on) and the original
diff --git a/tex/context/base/data-res.lua b/tex/context/base/data-res.lua
index f1ddb62aa..532b6261f 100644
--- a/tex/context/base/data-res.lua
+++ b/tex/context/base/data-res.lua
@@ -1303,7 +1303,7 @@ local function find_otherwise(filename,filetype,wantedfiles,allresults) -- other
end
-- we could have a loop over the 6 functions but then we'd have to
--- always analyze .. todo: use url split
+-- always analyze
collect_instance_files = function(filename,askedformat,allresults) -- uses nested
askedformat = askedformat or ""
diff --git a/tex/context/base/data-tmp.lua b/tex/context/base/data-tmp.lua
index 3e109dcfe..5025a8a0a 100644
--- a/tex/context/base/data-tmp.lua
+++ b/tex/context/base/data-tmp.lua
@@ -250,10 +250,6 @@ end
caches.getreadablepaths = getreadablepaths
caches.getwritablepath = getwritablepath
--- this can be tricky as we can have a pre-generated format while at the same time
--- use e.g. a home path where we have updated file databases and so maybe we need
--- to check first if we do have a writable one
-
function caches.getfirstreadablefile(filename,...)
local rd = getreadablepaths(...)
for i=1,#rd do
@@ -267,28 +263,6 @@ function caches.getfirstreadablefile(filename,...)
return caches.setfirstwritablefile(filename,...)
end
--- next time we have an issue, we can test this instead:
-
-function caches.getfirstreadablefile_TEST_ME_FIRST(filename,...)
- -- check if we have already written once
- local fullname, path = caches.setfirstwritablefile(filename,...)
- if is_readable(fullname) then
- return fullname, path -- , true
- end
- -- otherwise search for pregenerated
- local rd = getreadablepaths(...)
- for i=1,#rd do
- local path = rd[i]
- local fullname = file.join(path,filename)
- if is_readable(fullname) then
- usedreadables[i] = true
- return fullname, path -- , false
- end
- end
- -- else assume new written
- return fullname, path -- , true
-end
-
function caches.setfirstwritablefile(filename,...)
local wr = getwritablepath(...)
local fullname = file.join(wr,filename)
diff --git a/tex/context/base/data-vir.lua b/tex/context/base/data-vir.lua
index 48fec54e0..e5bf35fa7 100644
--- a/tex/context/base/data-vir.lua
+++ b/tex/context/base/data-vir.lua
@@ -58,7 +58,6 @@ function openers.virtual(specification)
end
data[original] = nil -- when we comment this we can have error messages
-- With utf-8 we signal that no regime is to be applied!
- -- characters.showstring(d)
return openers.helpers.textopener("virtual",original,d,"utf-8")
else
if trace_virtual then
diff --git a/tex/context/base/file-ini.lua b/tex/context/base/file-ini.lua
index 2bc742a1f..1872ed3d3 100644
--- a/tex/context/base/file-ini.lua
+++ b/tex/context/base/file-ini.lua
@@ -13,13 +13,13 @@ if not modules then modules = { } end modules ['file-ini'] = {
resolvers.jobs = resolvers.jobs or { }
-local texsetcount = tex.setcount
-local setvalue = context.setvalue
+local texcount = tex.count
+local setvalue = context.setvalue
function commands.splitfilename(fullname)
local t = file.nametotable(fullname)
local path = t.path
- texsetcount("splitoffkind",(path == "" and 0) or (path == '.' and 1) or 2)
+ texcount.splitoffkind = (path == "" and 0) or (path == '.' and 1) or 2
setvalue("splitofffull",fullname)
setvalue("splitoffpath",path)
setvalue("splitoffname",t.name)
diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi
index ce0d54ece..087f1a685 100644
--- a/tex/context/base/file-job.mkvi
+++ b/tex/context/base/file-job.mkvi
@@ -66,16 +66,14 @@
% \def\doloadsystemfile#1% only mkiv files
% {\readfile{sys:///#1.\mksuffix}{\showmessage\m!system2{#1.\mksuffix}}\donothing}
-\unexpanded\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}
+\unexpanded\def\loadsystemfiles
+ {\syst_files_load\f!newfilename % new code, to be integrated at some point, plus fixes posted on the list
+ \syst_files_load\f!locfilename % new code, somewhat experimental, not distributed (outside the dev group)
+ \syst_files_load\f!expfilename % new code, very experimental, can be engine specific, mostly for me only
+ \syst_files_load\f!sysfilename} % local settings, but probably not that good an idea to use
+
+\def\syst_files_load#name% only mkiv files
+ {\readsysfile{#name.\mksuffix}{\showmessage\m!system2{#name.\mksuffix}}\donothing}
% obsolete, but we keep it as reference of what happened
%
diff --git a/tex/context/base/file-mod.lua b/tex/context/base/file-mod.lua
index 822f37c86..3659d3089 100644
--- a/tex/context/base/file-mod.lua
+++ b/tex/context/base/file-mod.lua
@@ -27,8 +27,6 @@ local report_modules = logs.reporter("resolvers","modules")
commands = commands or { }
local commands = commands
-local context = context
-
local findbyscheme = resolvers.finders.byscheme -- use different one
local iterator = utilities.parsers.iterator
diff --git a/tex/context/base/file-mod.mkvi b/tex/context/base/file-mod.mkvi
index 00966a442..0dbd14bdb 100644
--- a/tex/context/base/file-mod.mkvi
+++ b/tex/context/base/file-mod.mkvi
@@ -104,8 +104,6 @@
\let\currentmoduleparameters\empty
\let\currentmodule \s!unknown
-\newtoks\everysetupmodule
-
\unexpanded\def\startmodule
{\doifnextoptionalelse\syst_modules_start_yes\syst_modules_start_nop}
@@ -133,8 +131,7 @@
\getparameters[\??module\currentmodule:][#name]% internal (defaults)
\normalexpanded{\getparameters[\??module\currentmodule:][\the\scratchtoks]}% loadtime (user)
\fi
- \let\currentmoduleparameters\empty
- \the\everysetupmodule}
+ \let\currentmoduleparameters\empty}
% to be tested:
%
@@ -148,7 +145,7 @@
% \fi
% \let\currentmoduleparameters\empty}
-\def\moduleparameter#name#parameter% should have been \namedmoduleparameter
+\def\moduleparameter#name#parameter%
{\csname\??module
\ifcsname\??module#name:#parameter\endcsname#name:#parameter\fi
\endcsname}
diff --git a/tex/context/base/font-afm.lua b/tex/context/base/font-afm.lua
index adb4281b2..cb0c2438f 100644
--- a/tex/context/base/font-afm.lua
+++ b/tex/context/base/font-afm.lua
@@ -54,8 +54,6 @@ afm.addligatures = true -- best leave this set to true
afm.addtexligatures = true -- best leave this set to true
afm.addkerns = true -- best leave this set to true
-local applyruntimefixes = fonts.treatments and fonts.treatments.applyfixes
-
local function setmode(tfmdata,value)
if value then
tfmdata.properties.mode = lower(value)
@@ -311,7 +309,7 @@ local addkerns, addligatures, addtexligatures, unify, normalize -- we will imple
function afm.load(filename)
-- hm, for some reasons not resolved yet
filename = resolvers.findfile(filename,'afm') or ""
- if filename ~= "" and not fonts.names.ignoredfile(filename) then
+ if filename ~= "" then
local name = file.removesuffix(file.basename(filename))
local data = containers.read(afm.cache,name)
local attr = lfs.attributes(filename)
@@ -362,9 +360,6 @@ function afm.load(filename)
data = containers.write(afm.cache, name, data)
data = containers.read(afm.cache,name)
end
- if applyruntimefixes and data then
- applyruntimefixes(filename,data)
- end
end
return data
else
@@ -642,10 +637,10 @@ local function copytotfm(data)
parameters.x_height = 400
parameters.quad = 1000
--
- if italicangle and italicangle ~= 0 then
+ if italicangle then
parameters.italicangle = italicangle
parameters.italicfactor = math.cos(math.rad(90+italicangle))
- parameters.slant = - math.tan(italicangle*math.pi/180)
+ parameters.slant = - math.round(math.tan(italicangle*math.pi/180))
end
if monospaced then
parameters.space_stretch = 0
diff --git a/tex/context/base/font-chk.lua b/tex/context/base/font-chk.lua
index 6dc1667bb..1b89366fd 100644
--- a/tex/context/base/font-chk.lua
+++ b/tex/context/base/font-chk.lua
@@ -9,9 +9,8 @@ if not modules then modules = { } end modules ['font-chk'] = {
-- possible optimization: delayed initialization of vectors
-- move to the nodes namespace
-local formatters = string.formatters
+local format = string.format
local bpfactor = number.dimenfactors.bp
-local fastcopy = table.fastcopy
local report_fonts = logs.reporter("fonts","checking")
@@ -24,11 +23,9 @@ local fonthashes = fonts.hashes
local fontdata = fonthashes.identifiers
local fontcharacters = fonthashes.characters
-local helpers = fonts.helpers
-
-local addprivate = helpers.addprivate
-local hasprivate = helpers.hasprivate
-local getprivatenode = helpers.getprivatenode
+local addprivate = fonts.helpers.addprivate
+local hasprivate = fonts.helpers.hasprivate
+local getprivatenode = fonts.helpers.getprivatenode
local otffeatures = fonts.constructors.newfeatures("otf")
local registerotffeature = otffeatures.register
@@ -68,7 +65,7 @@ local function onetimemessage(font,char,message) -- char == false returns table
if char == false then
return table.sortedkeys(category)
elseif not category[char] then
- report_fonts("char %C in font %a with id %a: %s",char,tfmdata.properties.fullname,font,message)
+ report_fonts("char %U in font %a with id %a: %s",char,tfmdata.properties.fullname,font,message)
category[char] = true
end
end
@@ -150,7 +147,7 @@ local variants = {
{ tag = "yellow", r = .6, g = .6, b = 0 },
}
-local pdf_blob = "pdf: q %0.6f 0 0 %0.6f 0 0 cm %s %s %s rg %s %s %s RG 10 M 1 j 1 J 0.05 w %s Q"
+local package = "q %0.6f 0 0 %0.6f 0 0 cm %s %s %s rg %s %s %s RG 10 M 1 j 1 J 0.05 w %s Q"
local cache = { } -- saves some tables but not that impressive
@@ -165,9 +162,9 @@ local function addmissingsymbols(tfmdata) -- we can have an alternative with rul
for i =1, #fakes do
local fake = fakes[i]
local name = fake.name
- local privatename = formatters["placeholder %s %s"](name,tag)
+ local privatename = format("placeholder %s %s",name,tag)
if not hasprivate(tfmdata,privatename) then
- local hash = formatters["%s_%s_%s_%s_%s_%s"](name,tag,r,g,b,size)
+ local hash = format("%s_%s_%s_%s_%s_%s",name,tag,r,g,b,size)
local char = cache[hash]
if not char then
char = {
@@ -175,7 +172,7 @@ local function addmissingsymbols(tfmdata) -- we can have an alternative with rul
height = size*fake.height,
depth = size*fake.depth,
-- bah .. low level pdf ... should be a rule or plugged in
- commands = { { "special", formatters[pdf_blob](scale,scale,r,g,b,r,g,b,fake.code) } }
+ commands = { { "special", "pdf: " .. format(package,scale,scale,r,g,b,r,g,b,fake.code) } }
}
cache[hash] = char
end
@@ -200,7 +197,7 @@ fonts.loggers.category_to_placeholder = mapping
function commands.getplaceholderchar(name)
local id = font.current()
addmissingsymbols(fontdata[id])
- context(helpers.getprivatenode(fontdata[id],name))
+ context(fonts.helpers.getprivatenode(fontdata[id],name))
end
function checkers.missing(head)
@@ -210,7 +207,6 @@ function checkers.missing(head)
local char = n.char
if font ~= lastfont then
characters = fontcharacters[font]
- lastfont = font
end
if not characters[char] and is_character[chardata[char].category] then
if action == "remove" then
@@ -361,35 +357,3 @@ luatex.registerstopactions(function()
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
diff --git a/tex/context/base/font-col.lua b/tex/context/base/font-col.lua
index b15997cba..20c99c9b4 100644
--- a/tex/context/base/font-col.lua
+++ b/tex/context/base/font-col.lua
@@ -7,7 +7,6 @@ if not modules then modules = { } end modules ['font-col'] = {
}
-- 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
@@ -16,12 +15,12 @@ local file, lpeg, table, string = file, lpeg, table, string
local type, next, toboolean = type, next, toboolean
local gmatch = string.gmatch
local fastcopy = table.fastcopy
+----- P, Cc, lpegmatch = lpeg.P, lpeg.Cc, lpeg.match
-local traverse_id = nodes.traverse_id
-
+local traverse_id = node.traverse_id
local settings_to_hash = utilities.parsers.settings_to_hash
-local trace_collecting = false trackers.register("fonts.collecting", function(v) trace_collecting = v end)
+local trace_collecting = false trackers.register("fonts.collecting", function(v) trace_collecting = v end)
local report_fonts = logs.reporter("fonts","collections")
@@ -44,22 +43,7 @@ local list = { }
local current = 0
local enabled = false
-local function checkenabled()
- -- a bit ugly but nicer than a fuzzy state while defining math
- if next(vectors) then
- if not enabled then
- nodes.tasks.enableaction("processors","fonts.collections.process")
- enabled = true
- end
- else
- if enabled then
- nodes.tasks.disableaction("processors","fonts.collections.process")
- enabled = false
- end
- end
-end
-
-collections.checkenabled = checkenabled
+-- maybe also a copy
function collections.reset(name,font)
if font and font ~= "" then
@@ -102,22 +86,8 @@ function collections.define(name,font,ranges,details)
end
end
end
- local offset = details.offset
- if type(offset) == "string" then
- local start = characters.getrange(offset)
- offset = start or false
- else
- offset = tonumber(offset) or false
- end
- d[#d+1] = {
- font = font,
- start = start,
- stop = stop,
- offset = offset,
- rscale = tonumber (details.rscale) or 1,
- force = toboolean(details.force,true),
- check = toboolean(details.check,true),
- }
+ details.font, details.start, details.stop = font, start, stop
+ d[#d+1] = fastcopy(details)
end
end
end
@@ -132,62 +102,57 @@ function collections.registermain(name)
list[#list+1] = last
end
--- check: when true, only set when present in font
--- force: when false, then not set when already set
-
function collections.clonevector(name)
statistics.starttiming(fonts)
+ local d = definitions[name]
+ local t = { }
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
- local cloneid = list[i]
- local oldchars = fontdata[current].characters
- local newchars = fontdata[cloneid].characters
+ for i=1,#d do
+ local f = d[i]
+ local id = list[i]
+ local start, stop = f.start, f.stop
if trace_collecting then
- report_fonts("remapping font %a to %a for range %U - %U",current,cloneid,start,stop)
+ report_fonts("remapping font %a to %a for range %U - %U",current,id,start,stop)
end
+ local check = toboolean(f.check or "false",true)
+ local force = toboolean(f.force or "true",true)
+ local remap = f.remap or nil
+ -- check: when true, only set when present in font
+ -- force: when false, then not set when already set
+ local oldchars = fontdata[current].characters
+ local newchars = fontdata[id].characters
if check then
- 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
+ for i=start,stop do
+ if newchars[i] and (force or (not t[i] and not oldchars[i])) then
if remap then
- vector[unic] = { cloneid, remap[unicode] }
+ t[i] = { id, remap[i] }
else
- vector[unic] = cloneid
+ t[i] = id
end
end
end
else
- for unicode = start, stop do
- local unic = unicode + offset - start
- if force or (not vector[unic] and not oldchars[unic]) then
+ for i=start,stop do
+ if force or (not t[i] and not oldchars[i]) then
if remap then
- vector[unic] = { cloneid, remap[unicode] }
+ t[i] = { id, remap[i] }
else
- vector[unic] = cloneid
+ t[i] = id
end
end
end
end
end
+ vectors[current] = t
if trace_collecting then
report_fonts("activating collection %a for font %a",name,current)
end
- checkenabled()
+ if not enabled then
+ nodes.tasks.enableaction("processors","fonts.collections.process")
+ enabled = true
+ end
statistics.stoptiming(fonts)
end
@@ -198,14 +163,11 @@ end
--
-- if lpegmatch(okay,name) then
-function collections.prepare(name) -- we can do this in lua now
+function collections.prepare(name)
current = currentfont()
if vectors[current] then
return
end
- if fontdata[current].mathparameters then
- return
- end
local d = definitions[name]
if d then
if trace_collecting then
@@ -251,13 +213,12 @@ function collections.process(head) -- this way we keep feature processing
if type(id) == "table" then
local newid, newchar = id[1], id[2]
if trace_collecting then
- report_fonts("remapping character %C in font %a to character %C in font %a",getchar(n),getfont(n),newchar,newid)
+ report_fonts("remapping character %a in font %a to character %a in font %a",n.char,n.font,newchar,newid)
end
- n.font = newid
- n.char = newchar
+ n.font, n.char = newid, newchar
else
if trace_collecting then
- report_fonts("remapping font %a to %a for character %C",getfont(n),id,getchar(n))
+ report_fonts("remapping font %a to %a for character %a",n.font,id,n.char)
end
n.font = id
end
diff --git a/tex/context/base/font-col.mkvi b/tex/context/base/font-col.mkvi
index 34a1b04a8..030e9aef7 100644
--- a/tex/context/base/font-col.mkvi
+++ b/tex/context/base/font-col.mkvi
@@ -15,8 +15,7 @@
%
% actually we can now do more at the lua end
-% todo : missing only, force always, multiple fallbacks with test, scale
-% beware : only english key/values
+% todo: missing only, force always, multiple fallbacks with test, scale
%
% \resetfontfallback [whatever]
%
diff --git a/tex/context/base/font-con.lua b/tex/context/base/font-con.lua
index 24b03222c..790d4877a 100644
--- a/tex/context/base/font-con.lua
+++ b/tex/context/base/font-con.lua
@@ -307,7 +307,6 @@ function constructors.scale(tfmdata,specification)
if tonumber(specification) then
specification = { size = specification }
end
- target.specification = specification
--
local scaledpoints = specification.size
local relativeid = specification.relativeid
@@ -380,13 +379,13 @@ function constructors.scale(tfmdata,specification)
targetproperties.mode = properties.mode or "base" -- inherited
--
local askedscaledpoints = scaledpoints
- local scaledpoints, delta = constructors.calculatescale(tfmdata,scaledpoints,nil,specification) -- no shortcut, dan be redefined
+ local scaledpoints, delta = constructors.calculatescale(tfmdata,scaledpoints) -- 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_per_em = units -- just a trigger for the backend
+ target.designsize = parameters.designsize -- not really needed so it muight become obsolete
+ target.units_per_em = units -- just a trigger for the backend (does luatex use this? if not it will go)
--
local direction = properties.direction or tfmdata.direction or 0 -- pointless, as we don't use omf fonts at all
target.direction = direction
@@ -475,13 +474,13 @@ function constructors.scale(tfmdata,specification)
--
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
+ local targetslant = (parameters.slant or parameters[1] or 0)
+ 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
@@ -842,7 +841,7 @@ function constructors.finalize(tfmdata)
end
--
if not parameters.designsize then
- parameters.designsize = tfmdata.designsize or (factors.pt * 10)
+ parameters.designsize = tfmdata.designsize or 655360
end
--
if not parameters.units then
@@ -1000,11 +999,21 @@ function constructors.hashinstance(specification,force)
size = math.round(constructors.scaled(size,designsizes[hash]))
specification.size = size
end
- if fallbacks then
- return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks
- else
- return hash .. ' @ ' .. tostring(size)
- end
+ -- local mathsize = specification.mathsize or 0
+ -- if mathsize > 0 then
+ -- local textsize = specification.textsize
+ -- if fallbacks then
+ -- return hash .. ' @ ' .. tostring(size) .. ' [ ' .. tostring(mathsize) .. ' : ' .. tostring(textsize) .. ' ] @ ' .. fallbacks
+ -- else
+ -- return hash .. ' @ ' .. tostring(size) .. ' [ ' .. tostring(mathsize) .. ' : ' .. tostring(textsize) .. ' ]'
+ -- end
+ -- else
+ if fallbacks then
+ return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks
+ else
+ return hash .. ' @ ' .. tostring(size)
+ end
+ -- end
end
function constructors.setname(tfmdata,specification) -- todo: get specification from tfmdata
@@ -1269,8 +1278,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report)
local whathandler = handlers[what]
local whatfeatures = whathandler.features
local whatprocessors = whatfeatures.processors
- local mode = properties.mode
- local processors = whatprocessors[mode]
+ local processors = whatprocessors[properties.mode]
if processors then
for i=1,#processors do
local step = processors[i]
@@ -1287,7 +1295,7 @@ function constructors.collectprocessors(what,tfmdata,features,trace,report)
end
end
elseif trace then
- report("no feature processors for mode %a for font %a",mode,properties.fullname)
+ report("no feature processors for mode %a for font %a",mode,tfmdata.properties.fullname)
end
end
return processes
@@ -1301,8 +1309,7 @@ function constructors.applymanipulators(what,tfmdata,features,trace,report)
local whathandler = handlers[what]
local whatfeatures = whathandler.features
local whatmanipulators = whatfeatures.manipulators
- local mode = properties.mode
- local manipulators = whatmanipulators[mode]
+ local manipulators = whatmanipulators[properties.mode]
if manipulators then
for i=1,#manipulators do
local step = manipulators[i]
@@ -1311,7 +1318,7 @@ function constructors.applymanipulators(what,tfmdata,features,trace,report)
if value then
local action = step.action
if trace then
- report("applying feature manipulator %a for mode %a for font %a",feature,mode,properties.fullname)
+ report("applying feature manipulator %a for mode %a for font %a",feature,mode,tfmdata.properties.fullname)
end
if action then
action(tfmdata,feature,value)
diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua
index 6c3402683..2583c6520 100644
--- a/tex/context/base/font-ctx.lua
+++ b/tex/context/base/font-ctx.lua
@@ -14,6 +14,7 @@ if not modules then modules = { } end modules ['font-ctx'] = {
local context, commands = context, commands
+local texcount, texsetcount = tex.count, tex.setcount
local format, gmatch, match, find, lower, gsub, byte = string.format, string.gmatch, string.match, string.find, string.lower, string.gsub, string.byte
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
@@ -34,7 +35,6 @@ local trace_designsize = false trackers.register("fonts.designsize", functio
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_features = logs.reporter("fonts","features")
local report_cummulative = logs.reporter("fonts","cummulative")
@@ -56,15 +56,8 @@ local fontgoodies = fonts.goodies
local helpers = fonts.helpers
local hashes = fonts.hashes
local currentfont = font.current
-
-local texgetattribute = tex.getattribute
-local texsetattribute = tex.setattribute
-local texgetdimen = tex.getdimen
-local texsetcount = tex.setcount
-local texget = tex.get
-
-local texdefinefont = tex.definefont
-local texsp = tex.sp
+local texattribute = tex.attribute
+local texdimen = tex.dimen
local fontdata = hashes.identifiers
local characters = hashes.chardata
@@ -74,8 +67,6 @@ local resources = hashes.resources
local csnames = hashes.csnames
local marks = hashes.markdata
local lastmathids = hashes.lastmathids
-local exheights = hashes.exheights
-local emwidths = hashes.emwidths
local designsizefilename = fontgoodies.designsizes.filename
@@ -123,11 +114,7 @@ end
-- this will move elsewhere ...
-function fonts.helpers.name(tfmdata)
- return file.basename(type(tfmdata) == "number" and properties[tfmdata].name or tfmdata.properties.name)
-end
-
-utilities.strings.formatters.add(formatters,"font:name", [["'"..fonts.helpers.name(%s).."'"]])
+utilities.strings.formatters.add(formatters,"font:name", [["'"..file.basename(%s.properties.name).."'"]])
utilities.strings.formatters.add(formatters,"font:features",[["'"..table.sequenced(%s," ",true).."'"]])
-- ... like font-sfm or so
@@ -170,24 +157,10 @@ commands.resetnullfont = definers.resetnullfont
-- 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,
+local needsnodemode = {
+ gpos_mark2mark = true,
+ gpos_mark2base = true,
+ gpos_mark2ligature = true,
}
otftables.scripts.auto = "automatic fallback to latn when no dflt present"
@@ -225,8 +198,6 @@ local function checkedscript(tfmdata,resources,features)
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
@@ -269,9 +240,6 @@ local function checkedmode(tfmdata,resources,features)
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
@@ -572,9 +540,6 @@ local function mergecontextfeatures(currentname,extraname,how,mergedname) -- str
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
@@ -587,16 +552,10 @@ local function mergecontextfeatures(currentname,extraname,how,mergedname) -- str
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
@@ -658,39 +617,19 @@ specifiers.definecontext = definecontext
-- we extend the hasher:
--- constructors.hashmethods.virtual = function(list)
--- local s = { }
--- local n = 0
--- for k, v in next, list do
--- n = n + 1
--- s[n] = k -- no checking on k
--- end
--- if n > 0 then
--- sort(s)
--- for i=1,n do
--- local k = s[i]
--- s[i] = k .. '=' .. tostring(list[k])
--- end
--- 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
- -- if v == true then
- -- s[n] = k .. '=true'
- -- elseif v == false then
- -- s[n] = k .. '=false'
- -- else
- -- s[n] = k .. "=" .. v
- -- end
- s[n] = k .. "=" .. tostring(v)
+ s[n] = k -- no checking on k
end
if n > 0 then
sort(s)
+ for i=1,n do
+ local k = s[i]
+ s[i] = k .. '=' .. tostring(list[k])
+ end
return concat(s,"+")
end
end
@@ -700,14 +639,14 @@ end
-- local withcache = { } -- concat might be less efficient than nested tables
--
-- local function withset(name,what)
--- local zero = texgetattribute(0)
+-- local zero = texattribute[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)
+-- texattribute[0] = done
-- end
--
-- local function withfnt(name,what,font)
@@ -718,7 +657,7 @@ end
-- done = registercontext(font,name,what)
-- withcache[hash] = done
-- end
--- texsetattribute(0,done)
+-- texattribute[0] = done
-- end
function specifiers.showcontext(name)
@@ -836,16 +775,12 @@ local value = C((leftparent * (1-rightparent)^0 * rightparent + (1-space)
local dimension = C((space/"" + P(1))^1)
local rest = C(P(1)^0)
local scale_none = Cc(0)
-local scale_at = P("at") * 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
-
-local specialscale = { [5] = "ht", [6] = "cp" }
+local scale_at = P("at") * Cc(1) * spaces * dimension -- value
+local scale_sa = P("sa") * Cc(2) * spaces * dimension -- value
+local scale_mo = P("mo") * Cc(3) * spaces * dimension -- value
+local scale_scaled = P("scaled") * Cc(4) * spaces * dimension -- value
-local sizepattern = spaces * (scale_at + scale_sa + scale_mo + scale_ht + scale_cp + scale_scaled + scale_none)
+local sizepattern = spaces * (scale_at + scale_sa + scale_mo + scale_scaled + scale_none)
local splitpattern = spaces * value * spaces * rest
function helpers.splitfontpattern(str)
@@ -893,18 +828,18 @@ function commands.definefont_one(str)
if size and size ~= "" then
local mode, size = lpegmatch(sizepattern,size)
if size and mode then
- texsetcount("scaledfontmode",mode)
+ texcount.scaledfontmode = mode
setsomefontsize(size)
else
- texsetcount("scaledfontmode",0)
+ texcount.scaledfontmode = 0
setemptyfontsize()
end
elseif true then
-- so we don't need to check in tex
- texsetcount("scaledfontmode",2)
+ texcount.scaledfontmode = 2
setemptyfontsize()
else
- texsetcount("scaledfontmode",0)
+ texcount.scaledfontmode = 0
setemptyfontsize()
end
specification = definers.makespecification(str,lookup,name,sub,method,detail,size)
@@ -923,7 +858,7 @@ local function nice_cs(cs)
end
function commands.definefont_two(global,cs,str,size,inheritancemode,classfeatures,fontfeatures,classfallbacks,fontfallbacks,
- mathsize,textsize,relativeid,classgoodies,goodies,classdesignsize,fontdesignsize,scaledfontmode)
+ mathsize,textsize,relativeid,classgoodies,goodies,classdesignsize,fontdesignsize)
if trace_defining then
report_defining("start stage two: %s (size %s)",str,size)
end
@@ -953,7 +888,6 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
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
@@ -962,7 +896,6 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
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
@@ -1030,11 +963,9 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
name,tfmdata,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks,classgoodies,goodies,classdesignsize,fontdesignsize)
end
csnames[tfmdata] = specification.cs
- texdefinefont(global,cs,tfmdata)
+ tex.definefont(global,cs,tfmdata)
-- resolved (when designsize is used):
- local size = fontdata[tfmdata].parameters.size or 0
- setsomefontsize(size .. "sp")
- texsetcount("scaledfontsize",size)
+ setsomefontsize((fontdata[tfmdata].parameters.size or 0) .. "sp")
lastfontid = tfmdata
else
-- setting the extra characters will move elsewhere
@@ -1046,12 +977,11 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
-- 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
--
- constructors.checkvirtualids(tfmdata) -- experiment, will become obsolete when slots can selfreference
local id = font.define(tfmdata)
csnames[id] = specification.cs
tfmdata.properties.id = id
definers.register(tfmdata,id) -- to be sure, normally already done
- texdefinefont(global,cs,id)
+ tex.definefont(global,cs,id)
constructors.cleanuptable(tfmdata)
constructors.finalize(tfmdata)
if trace_defining then
@@ -1059,9 +989,7 @@ function commands.definefont_two(global,cs,str,size,inheritancemode,classfeature
name,id,nice_cs(cs),classfeatures,fontfeatures,classfallbacks,fontfallbacks)
end
-- resolved (when designsize is used):
- local size = tfmdata.parameters.size or 655360
- setsomefontsize(size .. "sp")
- texsetcount("scaledfontsize",size)
+ setsomefontsize((tfmdata.parameters.size or 655360) .. "sp")
lastfontid = id
end
if trace_defining then
@@ -1102,7 +1030,7 @@ function definers.define(specification)
specification.detail = specification.detail or (detail ~= "" and detail) or ""
--
if type(specification.size) == "string" then
- specification.size = texsp(specification.size) or 655260
+ specification.size = tex.sp(specification.size) or 655260
end
--
specification.specification = "" -- not used
@@ -1126,17 +1054,16 @@ function definers.define(specification)
return -1, nil
elseif type(tfmdata) == "number" then
if cs then
- texdefinefont(specification.global,cs,tfmdata)
+ tex.definefont(specification.global,cs,tfmdata)
csnames[tfmdata] = cs
end
return tfmdata, fontdata[tfmdata]
else
- constructors.checkvirtualids(tfmdata) -- experiment, will become obsolete when slots can selfreference
local id = font.define(tfmdata)
tfmdata.properties.id = id
definers.register(tfmdata,id)
if cs then
- texdefinefont(specification.global,cs,id)
+ tex.definefont(specification.global,cs,id)
csnames[id] = cs
end
constructors.cleanuptable(tfmdata)
@@ -1156,7 +1083,7 @@ local n = 0
function definers.internal(specification,cs)
specification = specification or { }
local name = specification.name
- local size = specification.size and number.todimen(specification.size) or texgetdimen("bodyfontsize")
+ local size = specification.size and number.todimen(specification.size) or texdimen.bodyfontsize
local number = tonumber(specification.number)
local id = nil
if number then
@@ -1194,25 +1121,9 @@ end)
local calculatescale = constructors.calculatescale
-function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specification)
- if specification then
- local scalemode = specification.scalemode
- local special = scalemode and specialscale[scalemode]
- if special then
- -- we also have available specification.textsize
- local parameters = tfmdata.parameters
- local designsize = parameters.designsize
- if special == "ht" then
- local height = parameters.ascender * designsize / parameters.units
- scaledpoints = (scaledpoints/height) * designsize
- elseif special == "cp" then
- local height = (tfmdata.descriptions[utf.byte("X")].height or parameters.ascender) * designsize / parameters.units
- scaledpoints = (scaledpoints/height) * designsize
- end
- end
- end
- scaledpoints, delta = calculatescale(tfmdata,scaledpoints)
- -- if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific (we need to hash rscale then)
+function constructors.calculatescale(tfmdata,scaledpoints,relativeid)
+ local scaledpoints, delta = calculatescale(tfmdata,scaledpoints)
+ -- if enable_auto_r_scale and relativeid then -- for the moment this is rather context specific
-- local relativedata = fontdata[relativeid]
-- local rfmdata = relativedata and relativedata.unscaled and relativedata.unscaled
-- local id_x_height = rfmdata and rfmdata.parameters and rfmdata.parameters.x_height
@@ -1226,31 +1137,6 @@ function constructors.calculatescale(tfmdata,scaledpoints,relativeid,specificati
return scaledpoints, delta
end
-local designsizes = constructors.designsizes
-
-function constructors.hashinstance(specification,force)
- local hash, size, fallbacks = specification.hash, specification.size, specification.fallbacks
- if force or not hash then
- hash = constructors.hashfeatures(specification)
- specification.hash = hash
- end
- if size < 1000 and designsizes[hash] then
- size = math.round(constructors.scaled(size,designsizes[hash]))
- specification.size = size
- end
- if fallbacks then
- return hash .. ' @ ' .. tostring(size) .. ' @ ' .. fallbacks
- else
- local scalemode = specification.scalemode
- local special = scalemode and specialscale[scalemode]
- if special then
- return hash .. ' @ ' .. tostring(size) .. ' @ ' .. special
- else
- return hash .. ' @ ' .. tostring(size)
- end
- end
-end
-
-- We overload the (generic) resolver:
local resolvers = definers.resolvers
@@ -1517,11 +1403,11 @@ function commands.featureattribute(tag)
end
function commands.setfontfeature(tag)
- texsetattribute(0,contextnumber(tag))
+ texattribute[0] = contextnumber(tag)
end
function commands.resetfontfeature()
- texsetattribute(0,0)
+ texattribute[0] = 0
end
-- function commands.addfs(tag) withset(tag, 1) end
@@ -1577,11 +1463,11 @@ end
local dimenfactors = number.dimenfactors
-function helpers.dimenfactor(unit,id)
+function helpers.dimenfactor(unit,tfmdata) -- could be a method of a font instance
if unit == "ex" then
- return id and exheights[id] or 282460 -- lm 10pt
+ return (tfmdata and tfmdata.parameters.x_height) or 655360
elseif unit == "em" then
- return id and emwidths [id] or 655360 -- lm 10pt
+ return (tfmdata and tfmdata.parameters.em_width) or 655360
else
local du = dimenfactors[unit]
return du and 1/du or tonumber(unit) or 1
@@ -1672,24 +1558,19 @@ end
local quads = hashes.quads
local xheights = hashes.xheights
-setmetatableindex(dimenfactors, function(t,k)
+setmetatableindex(number.dimenfactors, function(t,k)
if k == "ex" then
- return 1/xheights[currentfont()]
+ return xheigths[currentfont()]
elseif k == "em" then
- return 1/quads[currentfont()]
- elseif k == "pct" or k == "%" then
- return 1/(texget("hsize")/100)
+ return quads[currentfont()]
+ elseif k == "%" then
+ return dimen.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.
@@ -1701,11 +1582,8 @@ function constructors.checkvirtualids(tfmdata)
local selfid = font.nextid()
if fonts and #fonts > 0 then
for i=1,#fonts do
- local fi = fonts[i]
- if fi[2] == 0 then
- fi[2] = selfid
- elseif fi.id == 0 then
- fi.id = selfid
+ if fonts[i][2] == 0 then
+ fonts[i][2] = selfid
end
end
else
@@ -1768,19 +1646,19 @@ local hows = {
["="] = "replace",
}
-function commands.feature(how,parent,name,font) -- 0/1 test temporary for testing
- if not how or how == 0 then
- if trace_features and texgetattribute(0) ~= 0 then
+function commands.feature(how,parent,name,font)
+ if not how then
+ if trace_features and texattribute[0] ~= 0 then
report_cummulative("font %!font:name!, reset",fontdata[font or true])
end
- texsetattribute(0,0)
- elseif how == true or how == 1 then
+ texattribute[0] = 0
+ elseif how == true 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
- texsetattribute(0,done or 0)
+ texattribute[0] = done or 0
else
local full = parent .. how .. name
local hash = "feature > " .. full
@@ -1798,7 +1676,7 @@ function commands.feature(how,parent,name,font) -- 0/1 test temporary for testin
report_cummulative("font %!font:name!, %s %a : %!font:features!",fontdata[font or true],hows[how],full,setups[numbers[done]])
end
end
- texsetattribute(0,done)
+ texattribute[0] = done
end
end
@@ -1925,7 +1803,7 @@ local function analyzeprocessor(head,font,attr)
end
registerotffeature { -- adapts
- name = "analyze",
+ name = "analyze",
processors = {
node = analyzeprocessor,
}
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index e5c5d990c..bee02e8dc 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -11,7 +11,6 @@ if not modules then modules = { } end modules ['font-def'] = {
local format, gmatch, match, find, lower, gsub = string.format, string.gmatch, string.match, string.find, string.lower, string.gsub
local tostring, next = tostring, next
local lpegmatch = lpeg.match
-local suffixonly, removesuffix = file.suffix, file.removesuffix
local allocate = utilities.storage.allocate
@@ -113,7 +112,7 @@ addlookup("name")
addlookup("spec")
local function getspecification(str)
- return lpegmatch(splitter,str or "") -- weird catch
+ return lpegmatch(splitter,str)
end
definers.getspecification = getspecification
@@ -170,13 +169,12 @@ local resolvers = definers.resolvers
function resolvers.file(specification)
local name = resolvefile(specification.name) -- catch for renames
- local suffix = lower(suffixonly(name))
+ local suffix = file.suffix(name)
if fonts.formats[suffix] then
- specification.forced = suffix
- specification.forcedname = name
- specification.name = removesuffix(name)
+ specification.forced = suffix
+ specification.name = file.removesuffix(name)
else
- specification.name = name -- can be resolved
+ specification.name = name -- can be resolved
end
end
@@ -187,13 +185,12 @@ function resolvers.name(specification)
if resolved then
specification.resolved = resolved
specification.sub = sub
- local suffix = lower(suffixonly(resolved))
+ local suffix = file.suffix(resolved)
if fonts.formats[suffix] then
- specification.forced = suffix
- specification.forcedname = resolved
- specification.name = removesuffix(resolved)
+ specification.forced = suffix
+ specification.name = file.removesuffix(resolved)
else
- specification.name = resolved
+ specification.name = resolved
end
end
else
@@ -206,11 +203,10 @@ function resolvers.spec(specification)
if resolvespec then
local resolved, sub = resolvespec(specification.name,specification.sub,specification) -- we pass specification for overloaded versions
if resolved then
- specification.resolved = resolved
- specification.sub = sub
- specification.forced = lower(suffixonly(resolved))
- specification.forcedname = resolved
- specification.name = removesuffix(resolved)
+ specification.resolved = resolved
+ specification.sub = sub
+ specification.forced = file.suffix(resolved)
+ specification.name = file.removesuffix(resolved)
end
else
resolvers.name(specification)
@@ -225,8 +221,9 @@ function definers.resolve(specification)
end
end
if specification.forced == "" then
- specification.forced = nil
- specification.forcedname = nil
+ specification.forced = nil
+ else
+ specification.forced = specification.forced
end
specification.hash = lower(specification.name .. ' @ ' .. constructors.hashfeatures(specification))
if specification.sub and specification.sub ~= "" then
@@ -297,7 +294,7 @@ function definers.loadfont(specification)
if not tfmdata then
local forced = specification.forced or ""
if forced ~= "" then
- local reader = readers[lower(forced)] -- normally forced is already lowered
+ local reader = readers[lower(forced)]
tfmdata = reader and reader(specification)
if not tfmdata then
report_defining("forced type %a of %a not found",forced,specification.name)
diff --git a/tex/context/base/font-emp.mkvi b/tex/context/base/font-emp.mkvi
index 34a1ea9cc..1713eda70 100644
--- a/tex/context/base/font-emp.mkvi
+++ b/tex/context/base/font-emp.mkvi
@@ -117,8 +117,6 @@
%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
diff --git a/tex/context/base/font-ext.lua b/tex/context/base/font-ext.lua
index ede2151d6..89d5927d4 100644
--- a/tex/context/base/font-ext.lua
+++ b/tex/context/base/font-ext.lua
@@ -469,7 +469,7 @@ end
registerotffeature {
name = "protrusion",
- description = "l/r margin character protrusion",
+ description = "shift characters into the left and or right margin",
initializers = {
base = initializeprotrusion,
node = initializeprotrusion,
@@ -728,8 +728,6 @@ registerotffeature {
-- local gray = { "special", "pdf: /Tr1 gs .75 g" }
-- local black = { "special", "pdf: /Tr0 gs 0 g" }
--- sort of obsolete as we now have \showglyphs
-
local push = { "push" }
local pop = { "pop" }
local gray = { "special", "pdf: .75 g" }
diff --git a/tex/context/base/font-fea.mkvi b/tex/context/base/font-fea.mkvi
index 777c6e3ca..c1e051621 100644
--- a/tex/context/base/font-fea.mkvi
+++ b/tex/context/base/font-fea.mkvi
@@ -164,7 +164,7 @@
\let\doaddfeature \font_feature_add_nop % low level faster ones
\let\dosubtractfeature \font_feature_subtract_nop
\let\doreplacefeature \font_feature_replace_nop
-\let\doresetandaddfeature\font_feature_reset_add_nop
+\let\doreserandaddfeature\font_feature_reset_add_nop
\unexpanded\def\font_feature_add
{\ifnum\c_font_feature_state=\plusone
@@ -330,12 +330,4 @@
\ctxcommand{registerlanguagefeatures()}
-% also new
-
-\unexpanded\def\useaddfontfeatureparameter#1% faster local variant
- {\edef\m_font_feature_asked{#1\c!features}%
- \ifx\m_font_feature_asked\empty\else
- \font_feature_add
- \fi}
-
\protect \endinput
diff --git a/tex/context/base/font-gds.lua b/tex/context/base/font-gds.lua
index 7f8bb91d1..6332f40b0 100644
--- a/tex/context/base/font-gds.lua
+++ b/tex/context/base/font-gds.lua
@@ -18,7 +18,6 @@ local trace_goodies = false trackers.register("fonts.goodies", function(v)
local report_goodies = logs.reporter("fonts","goodies")
local allocate = utilities.storage.allocate
-local setmetatableindex = table.setmetatableindex
local otf = fonts.handlers.otf
local afm = fonts.handlers.afm
@@ -44,10 +43,6 @@ local addotffeature = otf.enhancers.addfeature
local findfile = resolvers.findfile
-local glyph_code = nodes.nodecodes.glyph
-
-local traverse_id = nodes.traverse_id
-
function fontgoodies.report(what,trace,goodies)
if trace_goodies or trace then
local whatever = goodies[what]
@@ -303,104 +298,27 @@ local function setcolorscheme(tfmdata,scheme)
tfmdata.properties.colorscheme = false
end
-local fontproperties = fonts.hashes.properties
-
-local a_colorscheme = attributes.private('colorscheme')
-local setnodecolor = nodes.tracers.colors.set
-
--- function colorschemes.coloring(head)
--- local lastfont, lastscheme
--- local done = false
--- for n in traverse_id(glyph_code,head) do
--- local a = n[a_colorscheme]
--- if a then
--- local f = n.font
--- if f ~= lastfont then
--- lastscheme = fontproperties[f].colorscheme
--- lastfont = f
--- end
--- if lastscheme then
--- local sc = lastscheme[n.char]
--- if sc then
--- done = true
--- setnodecolor(n,"colorscheme:"..a..":"..sc) -- slow
--- end
--- end
--- end
--- end
--- return head, done
--- end
-
--- seldom used, mostly in manuals, so non critical .. anyhow, somewhat faster:
-
--- function colorschemes.coloring(head)
--- local lastfont = nil
--- local lastattr = nil
--- local lastscheme = nil
--- local lastprefix = nil
--- local done = nil
--- for n in traverse_id(glyph_code,head) do
--- local a = n[a_colorscheme]
--- if a then
--- if a ~= lastattr then
--- lastattr = a
--- lastprefix = "colorscheme:" .. a .. ":"
--- end
--- local f = n.font
--- if f ~= lastfont then
--- lastfont = f
--- lastscheme = fontproperties[f].colorscheme
--- end
--- if lastscheme then
--- local sc = lastscheme[n.char]
--- if sc then
--- setnodecolor(n,lastprefix .. sc) -- slow
--- done = true
--- end
--- end
--- end
--- end
--- return head, done
--- end
-
--- ok, in case we have hundreds of pages colored:
-
-local cache = { } -- this could be a weak table
-
-setmetatableindex(cache,function(t,a)
- local v = { }
- setmetatableindex(v,function(t,c)
- local v = "colorscheme:" .. a .. ":" .. c
- t[c] = v
- return c
- end)
- t[a]= v
- return v
-end)
+local fontdata = fonts.hashes.identifiers
+local setnodecolor = nodes.tracers.colors.set
+local traverse_id = node.traverse_id
+local a_colorscheme = attributes.private('colorscheme')
+local glyph = node.id("glyph")
function colorschemes.coloring(head)
- local lastfont = nil
- local lastattr = nil
- local lastcache = nil
- local lastscheme = nil
- local done = nil
- for n in traverse_id(glyph_code,head) do
+ local lastfont, lastscheme
+ local done = false
+ for n in traverse_id(glyph,head) do
local a = n[a_colorscheme]
if a then
local f = n.font
if f ~= lastfont then
- lastfont = f
- lastscheme = fontproperties[f].colorscheme
- end
- if a ~= lastattr then
- lastattr = a
- lastcache = cache[a]
+ lastscheme, lastfont = fontdata[f].properties.colorscheme, f
end
if lastscheme then
local sc = lastscheme[n.char]
if sc then
- setnodecolor(n,lastcache[sc]) -- we could inline this one
done = true
+ setnodecolor(n,"colorscheme:"..a..":"..sc) -- slow
end
end
end
@@ -773,7 +691,7 @@ function fontgoodies.designsizes.register(name,size,specification)
d.default = specification
else
if type(size) == "string" then
- size = texsp(size) -- hm
+ size = texsp(size)
end
local ranges = d.ranges
ranges[#ranges+1] = { size, specification }
@@ -832,45 +750,3 @@ registerotffeature {
node = finalize,
}
}
-
--- kern hackery:
---
--- yes : use goodies table
--- auto : assume features to be set (often ccmp only)
-
-local function setkeepligatures(tfmdata,value)
- if not tfmdata.properties.keptligatures then
- local goodies = tfmdata.goodies
- if goodies then
- for i=1,#goodies do
- local g = goodies[i]
- local letterspacing = g.letterspacing
- if letterspacing then
- local keptligatures = letterspacing.keptligatures
- if keptligatures then
- local unicodes = tfmdata.resources.unicodes
- local hash = { }
- for k, v in next, keptligatures do
- local u = unicodes[k]
- if u then
- hash[u] = true
- else
- -- error: unknown name
- end
- end
- tfmdata.properties.keptligatures = hash
- end
- end
- end
- end
- end
-end
-
-registerotffeature {
- name = "keepligatures",
- description = "keep ligatures in letterspacing",
- initializers = {
- base = setkeepligatures,
- node = setkeepligatures,
- }
-}
diff --git a/tex/context/base/font-hsh.lua b/tex/context/base/font-hsh.lua
index 773cc2b69..f5c80d705 100644
--- a/tex/context/base/font-hsh.lua
+++ b/tex/context/base/font-hsh.lua
@@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['font-hsh'] = {
license = "see context related readme files"
}
-local rawget = rawget
-
local setmetatableindex = table.setmetatableindex
local currentfont = font.current
local allocate = utilities.storage.allocate
@@ -29,7 +27,6 @@ local spaces = hashes.spaces or allocate()
local quads = hashes.quads or allocate() -- maybe also spacedata
local xheights = hashes.xheights or allocate()
local csnames = hashes.csnames or allocate() -- namedata
-local features = hashes.features or allocate()
local marks = hashes.marks or allocate()
local italics = hashes.italics or allocate()
local lastmathids = hashes.lastmathids or allocate()
@@ -45,15 +42,11 @@ hashes.spaces = spaces
hashes.quads = quads hashes.emwidths = quads
hashes.xheights = xheights hashes.exheights = xheights
hashes.csnames = csnames
-hashes.features = features
hashes.marks = marks
hashes.italics = italics
hashes.lastmathids = lastmathids
hashes.dynamics = dynamics
-local nodepool = nodes.pool
-local dummyglyph = nodepool.register(nodepool.glyph())
-
local nulldata = allocate {
name = "nullfont",
characters = { },
@@ -140,14 +133,14 @@ setmetatableindex(resources, function(t,k)
end
end)
-setmetatableindex(features, function(t,k)
+setmetatableindex(quads, function(t,k)
if k == true then
- return features[currentfont()]
+ return quads[currentfont()]
else
- local shared = identifiers[k].shared
- local features = shared and shared.features or { }
- t[k] = features
- return features
+ local parameters = parameters[k]
+ local quad = parameters and parameters.quad or 0
+ t[k] = quad
+ return quad
end
end)
@@ -190,43 +183,12 @@ setmetatableindex(marks, function(t,k)
end
end)
-setmetatableindex(quads, function(t,k)
- if k == true then
- return quads[currentfont()]
- else
- local parameters = rawget(parameters,k)
- local quad
- if parameters then
- quad = parameters.quad
- else
- dummyglyph.font = k
- dummyglyph.char = 0x2014 -- emdash
- quad = dummyglyph.width -- dirty trick
- end
- if not quad or quad == 0 then
- quad = 655360 -- lm 10pt
- end
- t[k] = quad
- return quad
- end
-end)
-
setmetatableindex(xheights, function(t,k)
if k == true then
return xheights[currentfont()]
else
- local parameters = rawget(parameters,k)
- local xheight
- if parameters then
- xheight = parameters.xheight
- else
- dummyglyph.font = k
- dummyglyph.char = 0x78 -- x
- xheight = dummyglyph.height -- dirty trick
- end
- if not xheight or xheight == 0 then
- xheight = 282460 -- lm 10pt
- end
+ local parameters = parameters[k]
+ local xheight = parameters and parameters.xheight or 0
t[k] = xheight
return xheight
end
diff --git a/tex/context/base/font-ini.mkvi b/tex/context/base/font-ini.mkvi
index 521901e05..5f7aaa92f 100644
--- a/tex/context/base/font-ini.mkvi
+++ b/tex/context/base/font-ini.mkvi
@@ -700,7 +700,6 @@
\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
@@ -756,9 +755,6 @@
\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
@@ -774,7 +770,7 @@
\else
\d_font_scaled_text_face\textface
\fi
- \edef\somefontspec{at \number\d_font_scaled_font_size sp}% probably no longer used, needs checking
+ \edef\somefontspec{at \number\d_font_scaled_font_size sp}%
\edef\somefontfile{\truefontname\somefontname}%
\ifx\somefontfile\s!unknown
\edef\somefontfile{\defaultfontfile}%
@@ -801,10 +797,9 @@
"\m_font_class_goodies", % experiment (not yet used)
"\m_font_goodies",
"\m_font_class_designsize",
- "\m_font_designsize",
- \number\scaledfontmode
+ "\m_font_designsize"
)}%
- \edef\somefontspec{at \number\scaledfontsize sp}% we need the resolved designsize (for fallbacks)
+ \edef\somefontspec{at \number\d_font_scaled_font_size sp}% we need the resolved designsize (for fallbacks)
\expandafter\let\expandafter\lastrawfontcall\csname#csname\endcsname
\the\everydefinefont
\c_font_feature_inheritance_mode\c_font_feature_inheritance_default}
@@ -1524,7 +1519,7 @@
\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
+ \ifcsname\csname\??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}%
@@ -1679,7 +1674,7 @@
\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
+ \font_helpers_define_unknown_font{#body}%
\fi
\ifcsname\??fontbodyknown\normalizedsetfont\endcsname
\localbodyfontsize\normalizedsetfont
@@ -1713,7 +1708,6 @@
\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.)
@@ -2136,37 +2130,6 @@
%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]%
-% {\pushmacro\fontclass
-% \switchtobodyfont[#1]%
-% \popmacro\fontclass
-% \ifx\fontclass\empty\else\setupbodyfont\relax\fi}
-
-\unexpanded\def\usebodyfont[#1]%
- {\pushmacro\fontclass
- \font_helpers_set_font\zerocount{#1}%
- \popmacro\fontclass
- \ifx\fontclass\empty \else
- \font_basics_setupbodyfont_nop
- \fi}
-
%D Handy for manuals:
\unexpanded\def\fontchar#character%
@@ -2265,7 +2228,6 @@
\unexpanded\def\fullrestoreglobalbodyfont
{\let\fontsize\defaultfontsize
\let\fontbody\defaultfontbody
- \let\fontface\defaultfontface
\currentxfontsize\zerocount
\let\fontclass\globalfontclass
\font_basics_switch_points\normalizedglobalbodyfontsize
@@ -2279,7 +2241,6 @@
\unexpanded\def\partialrestoreglobalbodyfont
{\let\fontsize\defaultfontsize
\let\fontbody\defaultfontbody
- \let\fontface\defaultfontface
\currentxfontsize\zerocount
\redoconvertfont
\tf
diff --git a/tex/context/base/font-lib.mkvi b/tex/context/base/font-lib.mkvi
index a664d9b3a..4bacef10b 100644
--- a/tex/context/base/font-lib.mkvi
+++ b/tex/context/base/font-lib.mkvi
@@ -32,8 +32,6 @@
\registerctxluafile{font-hsh}{1.001} % hashes used by context
\registerctxluafile{font-nod}{1.001}
-\registerctxluafile{font-trt}{1.001}
-
\registerctxluafile{font-oti}{1.001} % otf initialization
\registerctxluafile{font-ott}{1.001} % otf tables (first)
\registerctxluafile{font-otf}{1.001} % otf main
@@ -58,6 +56,7 @@
\registerctxluafile{font-vf} {1.001}
\registerctxluafile{font-enh}{1.001}
+\registerctxluafile{font-trt}{1.001}
\registerctxluafile{font-gds}{1.001}
\registerctxluafile{font-def}{1.001}
diff --git a/tex/context/base/font-map.lua b/tex/context/base/font-map.lua
index ce724b973..b3c8da0f6 100644
--- a/tex/context/base/font-map.lua
+++ b/tex/context/base/font-map.lua
@@ -261,51 +261,38 @@ function mappings.addtounicode(data,filename)
end
end
-- a.whatever or a_b_c.whatever or a_b_c (no numbers) a.b_
- --
- -- It is not trivial to find a solution that suits all fonts. We tried several alternatives
- -- and this one seems to work reasonable also with fonts that use less standardized naming
- -- schemes. The extra private test is tested by KE and seems to work okay with non-typical
- -- fonts as well.
- --
- -- The next time I look into this, I'll add an extra analysis step to the otf loader (we can
- -- resolve some tounicodes by looking into the gsub data tables that are bound to glyphs.
- --
if not unicode or unicode == "" then
local split = lpegmatch(namesplitter,name)
local nsplit = split and #split or 0
- local t, n = { }, 0
- unicode = true
- for l=1,nsplit do
- local base = split[l]
- local u = unicodes[base] or unicodevector[base]
- if not u then
- break
- elseif type(u) == "table" then
- if u[1] >= private then
- unicode = false
+ if nsplit >= 2 then
+ local t, n = { }, 0
+ for l=1,nsplit do
+ local base = split[l]
+ local u = unicodes[base] or unicodevector[base]
+ if not u then
break
+ elseif type(u) == "table" then
+ n = n + 1
+ t[n] = u[1]
+ else
+ n = n + 1
+ t[n] = u
end
- n = n + 1
- t[n] = u[1]
+ end
+ if n == 0 then -- done then
+ -- nothing
+ elseif n == 1 then
+ originals[index] = t[1]
+ tounicode[index] = tounicode16(t[1],name)
else
- if u >= private then
- unicode = false
- break
- end
- n = n + 1
- t[n] = u
+ originals[index] = t
+ tounicode[index] = tounicode16sequence(t)
end
- end
- if n == 0 then -- done then
- -- nothing
- elseif n == 1 then
- originals[index] = t[1]
- tounicode[index] = tounicode16(t[1],name)
+ nl = nl + 1
+ unicode = true
else
- originals[index] = t
- tounicode[index] = tounicode16sequence(t)
+ -- skip: already checked and we don't want privates here
end
- nl = nl + 1
end
-- last resort (we might need to catch private here as well)
if not unicode or unicode == "" then
diff --git a/tex/context/base/font-mat.mkvi b/tex/context/base/font-mat.mkvi
index c8ee2630b..4fe44a2da 100644
--- a/tex/context/base/font-mat.mkvi
+++ b/tex/context/base/font-mat.mkvi
@@ -66,8 +66,8 @@
\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
+\newconditional\c_font_bidirectional_math_strategy % can be default, not that much overhead: \settrue\c_font_bidirectional_math_strategy
+\newconditional\c_font_complete_bold_math_strategy \settrue\c_font_complete_bold_math_strategy
\def\mathtextsuffix {-text}
\def\mathscriptsuffix {-script}
@@ -224,9 +224,9 @@
\edef\m_font_class_direction{\ifcsname\??fontclass\fontclass\s!mm\s!direction\endcsname\csname\??fontclass\fontclass\s!mm\s!direction\endcsname\fi}%
% ...
\ifx\m_font_class_direction\v!both
- \settrue\c_font_bidirectional_mathstrategy
+ \settrue\c_font_bidirectional_math_strategy
\else
- \setfalse\c_font_bidirectional_mathstrategy
+ \setfalse\c_font_bidirectional_math_strategy
\fi
\to \t_font_math_strategies
@@ -257,32 +257,32 @@
\scriptscriptfont\c_font_fam_mr_lr\scriptscriptfont\c_font_fam_mr}
\appendtoks
- \ifconditional\c_font_bidirectional_mathstrategy
+ \ifconditional\c_font_bidirectional_math_strategy
\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
+\def\font_helpers_complete_bold_math_strategy_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
+ \font_helpers_complete_bold_math_strategy_yes_bidi_changed
\fi}
-\def\font_helpers_complete_bold_mathstrategy_yes_bidi_changed
+\def\font_helpers_complete_bold_math_strategy_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
+\def\font_helpers_complete_bold_math_strategy_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
+ \font_helpers_complete_bold_math_strategy_yes_changed
\fi}
-\def\font_helpers_complete_bold_mathstrategy_yes_changed
+\def\font_helpers_complete_bold_math_strategy_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
@@ -290,12 +290,12 @@
\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
+\def\font_helpers_complete_bold_math_strategy_nop
{\ifnum\fontid\textfont\c_font_fam_mb=\fontid\textfont\c_font_fam_mr\else
- \font_helpers_complete_bold_mathstrategy_nop_changed
+ \font_helpers_complete_bold_math_strategy_nop_changed
\fi}
-\def\font_helpers_complete_bold_mathstrategy_nop_changed
+\def\font_helpers_complete_bold_math_strategy_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
@@ -306,19 +306,19 @@
\scriptfont \c_font_fam_mb_lr\scriptfont \c_font_fam_mr_lr
\scriptscriptfont\c_font_fam_mb_lr\scriptscriptfont\c_font_fam_mr_lr}
-\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
+\def\font_helpers_apply_complete_bold_math_strategy
+ {\ifconditional\c_font_complete_bold_math_strategy
+ \ifconditional\c_font_bidirectional_math_strategy
+ \font_helpers_complete_bold_math_strategy_yes_bidi
\else
- \font_helpers_complete_bold_mathstrategy_yes
+ \font_helpers_complete_bold_math_strategy_yes
\fi
\else
- \font_helpers_complete_bold_mathstrategy_nop
+ \font_helpers_complete_bold_math_strategynop
\fi}
\appendtoks
- \font_helpers_apply_complete_bold_mathstrategy
+ \font_helpers_apply_complete_bold_math_strategy
\to \t_font_math_strategies
\ifdefined\defaultmathfamily \else
@@ -330,7 +330,7 @@
\to \everymathematics
\unexpanded\def\font_helpers_synchronize_math_family_mr
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
+ {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
\ifconditional\c_math_right_to_left
\plustwo
\else
@@ -341,7 +341,7 @@
\fi}
\unexpanded\def\font_helpers_synchronize_math_family_mb
- {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_mathstrategy
+ {\attribute\mathfamilyattribute\ifconditional\c_font_bidirectional_math_strategy
\ifconditional\c_math_right_to_left
\ifconditional\c_font_pseudo_bold_math_state\pluseight\else\plusfive\fi
\else
diff --git a/tex/context/base/font-mis.lua b/tex/context/base/font-mis.lua
index 0796356c4..83df65341 100644
--- a/tex/context/base/font-mis.lua
+++ b/tex/context/base/font-mis.lua
@@ -22,7 +22,7 @@ local handlers = fonts.handlers
handlers.otf = handlers.otf or { }
local otf = handlers.otf
-otf.version = otf.version or 2.745
+otf.version = otf.version or 2.743
otf.cache = otf.cache or containers.define("fonts", "otf", otf.version, true)
function otf.loadcached(filename,format,sub)
diff --git a/tex/context/base/font-nod.lua b/tex/context/base/font-nod.lua
index 7fa3297d4..f99130279 100644
--- a/tex/context/base/font-nod.lua
+++ b/tex/context/base/font-nod.lua
@@ -41,12 +41,10 @@ tracers.characters = char_tracers
local step_tracers = tracers.steppers or { }
tracers.steppers = step_tracers
-local texsetbox = tex.setbox
-
-local copy_node_list = nodes.copy_list
-local hpack_node_list = nodes.hpack
-local free_node_list = nodes.flush_list
-local traverse_nodes = nodes.traverse
+local copy_node_list = node.copy_list
+local hpack_node_list = node.hpack
+local free_node_list = node.flush_list
+local traverse_nodes = node.traverse
local nodecodes = nodes.nodecodes
local whatcodes = nodes.whatcodes
@@ -234,8 +232,7 @@ end
function step_tracers.glyphs(n,i)
local c = collection[i]
if c then
- local b = hpack_node_list(copy_node_list(c)) -- multiple arguments
- texsetbox(n,b)
+ tex.box[n] = hpack_node_list(copy_node_list(c))
end
end
diff --git a/tex/context/base/font-odv.lua b/tex/context/base/font-odv.lua
index 69f74dfa5..b518fb79c 100644
--- a/tex/context/base/font-odv.lua
+++ b/tex/context/base/font-odv.lua
@@ -58,7 +58,7 @@ if not modules then modules = { } end modules ['font-odv'] = {
-- local function ms_matra(c)
-- local prebase, abovebase, belowbase, postbase = true, true, true, true
-- local n = c.next
--- while n and n.id == glyph_code and n.subtype < 256 and n.font == font do
+-- while n and n.id == glyph_code and n.subtype<256 and n.font == font do
-- local char = n.char
-- if not dependent_vowel[char] then
-- break
@@ -83,6 +83,7 @@ if not modules then modules = { } end modules ['font-odv'] = {
local insert, imerge = table.insert, table.imerge
local next = next
+local trace_analyzing = false trackers.register("otf.analyzing", function(v) trace_analyzing = v end)
local report_devanagari = logs.reporter("otf","devanagari")
fonts = fonts or { }
@@ -100,11 +101,13 @@ local methods = fonts.analyzers.methods
local otffeatures = fonts.constructors.newfeatures("otf")
local registerotffeature = otffeatures.register
-local insert_node_after = nodes.insert_after
-local copy_node = nodes.copy
-local free_node = nodes.free
-local remove_node = nodes.remove
-local flush_list = nodes.flush_list
+local processcharacters = nodes.handlers.characters
+
+local insert_node_after = node.insert_after
+local copy_node = node.copy
+local free_node = node.free
+local remove_node = node.remove
+local flush_list = node.flush_list
local unsetvalue = attributes.unsetvalue
@@ -123,41 +126,11 @@ local s_pref = states.pref
local s_blwf = states.blwf
local s_pstf = states.pstf
-local replace_all_nbsp = nil
-
-replace_all_nbsp = function(head) -- delayed definition
- replace_all_nbsp = typesetters and typesetters.characters and typesetters.characters.replacenbspaces or function(head)
- return head
- end
- return replace_all_nbsp(head)
-end
-
-local fontprocesses = fonts.hashes.processes
-local xprocesscharacters = nil
-
-xprocesscharacters = function(head,font)
- xprocesscharacters = nodes.handlers.characters
- return xprocesscharacters(head,font)
-end
-
-local function processcharacters(head,font)
- return xprocesscharacters(head)
-end
-
--- function processcharacters(head,font)
--- local processors = fontprocesses[font]
--- for i=1,#processors do
--- head = processors[i](head,font,0)
--- end
--- return head, true
--- end
-
-- In due time there will be entries here for scripts like Bengali, Gujarati,
-- Gurmukhi, Kannada, Malayalam, Oriya, Tamil, Telugu. Feel free to provide the
-- code points.
local consonant = {
- -- devanagari
[0x0915] = true, [0x0916] = true, [0x0917] = true, [0x0918] = true,
[0x0919] = true, [0x091A] = true, [0x091B] = true, [0x091C] = true,
[0x091D] = true, [0x091E] = true, [0x091F] = true, [0x0920] = true,
@@ -170,22 +143,9 @@ local consonant = {
[0x0939] = true, [0x0958] = true, [0x0959] = true, [0x095A] = true,
[0x095B] = true, [0x095C] = true, [0x095D] = true, [0x095E] = true,
[0x095F] = true, [0x0979] = true, [0x097A] = true,
- -- kannada
- [0x0C95] = true, [0x0C96] = true, [0x0C97] = true, [0x0C98] = true,
- [0x0C99] = true, [0x0C9A] = true, [0x0C9B] = true, [0x0C9C] = true,
- [0x0C9D] = true, [0x0C9E] = true, [0x0C9F] = true, [0x0CA0] = true,
- [0x0CA1] = true, [0x0CA2] = true, [0x0CA3] = true, [0x0CA4] = true,
- [0x0CA5] = true, [0x0CA6] = true, [0x0CA7] = true, [0x0CA8] = true,
- [0x0CA9] = true, [0x0CAA] = true, [0x0CAB] = true, [0x0CAC] = true,
- [0x0CAD] = true, [0x0CAE] = true, [0x0CAF] = true, [0x0CB0] = true,
- [0x0CB1] = true, [0x0CB2] = true, [0x0CB3] = true, [0x0CB4] = true,
- [0x0CB5] = true, [0x0CB6] = true, [0x0CB7] = true, [0x0CB8] = true,
- [0x0CB9] = true,
- [0x0CDE] = true, -- obsolete
}
local independent_vowel = {
- -- devanagari
[0x0904] = true, [0x0905] = true, [0x0906] = true, [0x0907] = true,
[0x0908] = true, [0x0909] = true, [0x090A] = true, [0x090B] = true,
[0x090C] = true, [0x090D] = true, [0x090E] = true, [0x090F] = true,
@@ -193,32 +153,20 @@ local independent_vowel = {
[0x0914] = true, [0x0960] = true, [0x0961] = true, [0x0972] = true,
[0x0973] = true, [0x0974] = true, [0x0975] = true, [0x0976] = true,
[0x0977] = true,
- -- kannada
- [0x0C85] = true, [0x0C86] = true, [0x0C87] = true, [0x0C88] = true,
- [0x0C89] = true, [0x0C8A] = true, [0x0C8B] = true, [0x0C8C] = true,
- [0x0C8D] = true, [0x0C8E] = true, [0x0C8F] = true, [0x0C90] = true,
- [0x0C91] = true, [0x0C92] = true, [0x0C93] = true, [0x0C94] = true,
}
local dependent_vowel = { -- matra
- -- devanagari
[0x093A] = true, [0x093B] = true, [0x093E] = true, [0x093F] = true,
[0x0940] = true, [0x0941] = true, [0x0942] = true, [0x0943] = true,
[0x0944] = true, [0x0945] = true, [0x0946] = true, [0x0947] = true,
[0x0948] = true, [0x0949] = true, [0x094A] = true, [0x094B] = true,
[0x094C] = true, [0x094E] = true, [0x094F] = true, [0x0955] = true,
[0x0956] = true, [0x0957] = true, [0x0962] = true, [0x0963] = true,
- -- kannada
- [0x0CBE] = true, [0x0CBF] = true, [0x0CC0] = true, [0x0CC1] = true,
- [0x0CC2] = true, [0x0CC3] = true, [0x0CC4] = true, [0x0CC5] = true,
- [0x0CC6] = true, [0x0CC7] = true, [0x0CC8] = true, [0x0CC9] = true,
- [0x0CCA] = true, [0x0CCB] = true, [0x0CCC] = true,
}
local vowel_modifier = {
- -- devanagari
[0x0900] = true, [0x0901] = true, [0x0902] = true, [0x0903] = true,
- -- A8E0 - A8F1 are cantillation marks for the Samaveda and may not belong here.
+ -- A8E0 - A8F1 are cantillation marks for the Samaveda and may not belong here.
[0xA8E0] = true, [0xA8E1] = true, [0xA8E2] = true, [0xA8E3] = true,
[0xA8E4] = true, [0xA8E5] = true, [0xA8E6] = true, [0xA8E7] = true,
[0xA8E8] = true, [0xA8E9] = true, [0xA8EA] = true, [0xA8EB] = true,
@@ -230,21 +178,9 @@ local stress_tone_mark = {
[0x0951] = true, [0x0952] = true, [0x0953] = true, [0x0954] = true,
}
-local nukta = {
- -- devanagari
- [0x093C] = true,
- -- kannada:
- [0x0CBC] = true,
-}
-
-local halant = {
- -- devanagari
- [0x094D] = true,
- -- kannada
- [0x0CCD] = true,
-}
-
-local c_ra = 0x0930 -- used to be tables (also used as constant)
+local c_nukta = 0x093C -- used to be tables
+local c_halant = 0x094D -- used to be tables
+local c_ra = 0x0930 -- used to be tables
local c_anudatta = 0x0952 -- used to be tables
local c_nbsp = 0x00A0 -- used to be tables
local c_zwnj = 0x200C -- used to be tables
@@ -255,19 +191,6 @@ local zw_char = { -- could also be inlined
[0x200D] = true,
}
--- 0C82 anusvara
--- 0C83 visarga
--- 0CBD avagraha
--- 0CD5 length mark
--- 0CD6 ai length mark
--- 0CE0 letter ll
--- 0CE1 letter rr
--- 0CE2 vowel sign l
--- 0CE2 vowel sign ll
--- 0CF1 sign
--- 0CF2 sign
--- OCE6 - OCEF digits
-
local pre_mark = {
[0x093F] = true, [0x094E] = true,
}
@@ -309,11 +232,10 @@ for k, v in next, below_mark do mark_above_below_post[k] = below_mark end
for k, v in next, post_mark do mark_above_below_post[k] = post_mark end
-- Again, this table can be extended for other scripts than devanagari. Actually,
--- for ConTeXt this kind of data is kept elsewhere so eventually we might move
+-- for ConTeXt this kind of dat is kept elsewhere so eventually we might move
-- tables to someplace else.
local reorder_class = {
- -- devanagari
[0x0930] = "before postscript",
[0x093F] = "before half",
[0x0940] = "after subscript",
@@ -332,20 +254,6 @@ local reorder_class = {
[0x0962] = "after subscript",
[0x0963] = "after subscript",
[0x093E] = "after subscript",
- -- kannada:
- [0x0CB0] = "after postscript", -- todo in code below
- [0x0CBF] = "before subscript", -- todo in code below
- [0x0CC6] = "before subscript", -- todo in code below
- [0x0CCC] = "before subscript", -- todo in code below
- [0x0CBE] = "before subscript", -- todo in code below
- [0x0CE2] = "before subscript", -- todo in code below
- [0x0CE3] = "before subscript", -- todo in code below
- [0x0CC1] = "before subscript", -- todo in code below
- [0x0CC2] = "before subscript", -- todo in code below
- [0x0CC3] = "after subscript",
- [0x0CC4] = "after subscript",
- [0x0CD5] = "after subscript",
- [0x0CD6] = "after subscript",
}
-- We use some pseudo features as we need to manipulate the nodelist based
@@ -549,22 +457,22 @@ local function deva_initialize(font,attr)
end
-local function deva_reorder(head,start,stop,font,attr,nbspaces)
+local function deva_reorder(head,start,stop,font,attr)
local lookuphash, reph, vattu, blwfcache = deva_initialize(font,attr) -- could be inlines but ugly
- local current = start
- local n = start.next
- local base = nil
+ local current = start
+ local n = start.next
+ local base = nil
local firstcons = nil
- local lastcons = nil
+ local lastcons = nil
local basefound = false
- if start.char == c_ra and halant[n.char] and reph then
+ if start.char == c_ra and n.char == c_halant and reph then
-- if syllable starts with Ra + H and script has 'Reph' then exclude Reph
-- from candidates for base consonants
if n == stop then
- return head, stop, nbspaces
+ return head, stop
end
if n.next.char == c_zwj then
current = start
@@ -580,31 +488,28 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
stop = stop.prev
head = remove_node(head,current)
free_node(current)
- return head, stop, nbspaces
+ return head, stop
else
- nbspaces = nbspaces + 1
- base = current
- firstcons = current
- lastcons = current
- current = current.next
+ base, firstcons, lastcons = current, current, current
+ current = current.next
if current ~= stop then
- if nukta[current.char] then
+ if current.char == c_nukta then
current = current.next
end
if current.char == c_zwj then
if current ~= stop then
local next = current.next
- if next ~= stop and halant[next.char] then
+ if next ~= stop and next.char == c_halant then
current = next
next = current.next
- local tmp = next and next.next or nil -- needs checking
+ local tmp = next.next
local changestop = next == stop
local tempcurrent = copy_node(next)
local nextcurrent = copy_node(current)
tempcurrent.next = nextcurrent
nextcurrent.prev = tempcurrent
tempcurrent[a_state] = s_blwf
- tempcurrent = processcharacters(tempcurrent,font)
+ tempcurrent = processcharacters(tempcurrent)
tempcurrent[a_state] = unsetvalue
if next.char == tempcurrent.char then
flush_list(tempcurrent)
@@ -615,9 +520,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
current.char = tempcurrent.char -- (assumes that result of blwf consists of one node)
local freenode = current.next
current.next = tmp
- if tmp then
- tmp.prev = current
- end
+ tmp.prev = current
free_node(freenode)
flush_list(tempcurrent)
if changestop then
@@ -656,14 +559,14 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
-- if base consonant is not last one then move halant from base consonant to last one
local np = base
local n = base.next
- if nukta[n.char] then
+ if n.char == c_nukta then
np = n
n = n.next
end
- if halant[n.char] then
+ if n.char == c_halant then
if lastcons ~= stop then
local ln = lastcons.next
- if nukta[ln.char] then
+ if ln.char == c_nukta then
lastcons = ln
end
end
@@ -685,8 +588,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
end
n = start.next
- -- if start.char == c_ra and halant[n.char] and not (n ~= stop and zw_char[n.next.char]) then
- if n ~= stop and start.char == c_ra and halant[n.char] and not zw_char[n.next.char] then
+ if start.char == c_ra and n.char == c_halant and not (n ~= stop and zw_char[n.next.char]) then
-- if syllable starts with Ra + H then move this combination so that it follows either:
-- the post-base 'matra' (if any) or the base consonant
local matra = base
@@ -723,7 +625,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
local current = start
while current ~= stop do
local next = current.next
- if next ~= stop and halant[next.char] and next.next.char == c_zwnj then
+ if next ~= stop and next.char == c_halant and next.next.char == c_zwnj then
current[a_state] = unsetvalue
end
current = next
@@ -731,7 +633,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
if base ~= stop and base[a_state] then
local next = base.next
- if halant[next.char] and not (next ~= stop and next.next.char == c_zwj) then
+ if next.char == c_halant and not (next ~= stop and next.next.char == c_zwj) then
base[a_state] = unsetvalue
end
end
@@ -743,7 +645,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
local current, allreordered, moved = start, false, { [base] = true }
local a, b, p, bn = base, base, base, base.next
- if base ~= stop and nukta[bn.char] then
+ if base ~= stop and bn.char == c_nukta then
a, b, p = bn, bn, bn
end
while not allreordered do
@@ -752,12 +654,12 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
local n = current.next
local l = nil -- used ?
if c ~= stop then
- if nukta[n.char] then
+ if n.char == c_nukta then
c = n
n = n.next
end
if c ~= stop then
- if halant[n.char] then
+ if n.char == c_halant then
c = n
n = n.next
end
@@ -817,7 +719,7 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
while current ~= stop do
local c = current
local n = current.next
- if current.char == c_ra and halant[n.char] then
+ if current.char == c_ra and n.char == c_halant then
c = n
n = n.next
local b, bn = base, base
@@ -880,17 +782,10 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
end
else
local char = current.char
- if consonant[char] then
+ if consonant[char] or char == c_nbsp then -- maybe combined hash
cns = current
local next = cns.next
- if halant[next.char] then
- cns = next
- end
- elseif char == c_nbsp then
- nbspaces = nbspaces + 1
- cns = current
- local next = cns.next
- if halant[next.char] then
+ if next.char == c_halant then
cns = next
end
end
@@ -900,12 +795,11 @@ local function deva_reorder(head,start,stop,font,attr,nbspaces)
end
if base.char == c_nbsp then
- nbspaces = nbspaces - 1
head = remove_node(head,base)
free_node(base)
end
- return head, stop, nbspaces
+ return head, stop
end
-- If a pre-base matra character had been reordered before applying basic features,
@@ -924,7 +818,7 @@ function handlers.devanagari_reorder_matras(head,start,kind,lookupname,replaceme
-- can be fast loop
while current and current.id == glyph_code and current.subtype<256 and current.font == font and current[a_syllabe] == startattr do
local next = current.next
- if halant[current.char] and not current[a_state] then
+ if current.char == c_halant and not current[a_state] then
if next and next.id == glyph_code and next.subtype<256 and next.font == font and next[a_syllabe] == startattr and zw_char[next.char] then
current = next
end
@@ -978,7 +872,7 @@ function handlers.devanagari_reorder_reph(head,start,kind,lookupname,replacement
local startfont = start.font
local startattr = start[a_syllabe]
while current and current.id == glyph_code and current.subtype<256 and current.font == startfont and current[a_syllabe] == startattr do --step 2
- if halant[current.char] and not current[a_state] then
+ if current.char == c_halant and not current[a_state] then
local next = current.next
if next and next.id == glyph_code and next.subtype<256 and next.font == startfont and next[a_syllabe] == startattr and zw_char[next.char] then
current = next
@@ -1091,7 +985,7 @@ function handlers.devanagari_reorder_pre_base_reordering_consonants(head,start,k
-- can be fast for loop + caching state
while current and current.id == glyph_code and current.subtype<256 and current.font == startfont and current[a_syllabe] == startattr do
local next = current.next
- if halant[current.char] and not current[a_state] then
+ if current.char == c_halant and not current[a_state] then
if next and next.id == glyph_code and next.subtype<256 and next.font == font and next[a_syllabe] == startattr then
local char = next.char
if char == c_zwnj or char == c_zwj then
@@ -1152,9 +1046,6 @@ function handlers.devanagari_remove_joiners(head,start,kind,lookupname,replaceme
if prev then
prev.next = stop
end
- if head == start then
- head = stop
- end
flush_list(start)
return head, stop, true
end
@@ -1235,18 +1126,13 @@ end
-- this one will be merged into the caller: it saves a call, but we will then make function
-- of the actions
-local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pass over (determine stop in sweep)
+local function dev2_reorder(head,start,stop,font,attr) -- maybe do a pass over (determine stop in sweep)
local lookuphash, seqsubset = dev2_initialize(font,attr)
- local pre_base_reordering_consonants = { } -- was nil ... probably went unnoticed because never assigned
-
- local reph = false -- was nil ... probably went unnoticed because never assigned
- local halfpos = nil
- local basepos = nil
- local subpos = nil
- local postpos = nil
- local locl = { }
+ local reph, pre_base_reordering_consonants = false, { } -- was nil ... probably went unnoticed because never assigned
+ local halfpos, basepos, subpos, postpos = nil, nil, nil, nil
+ local locl = { }
for i=1,#seqsubset do
@@ -1256,15 +1142,8 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
local kind = subset[1]
local lookupcache = subset[2]
if kind == "rphf" then
- -- todo: rphf might be result of other handler/chainproc
- -- todo: rphf actualy acts on consonant + halant.
- -- todo: the consonant might not necesseraly be 0x0930 ... (but for devanagari it is)
- local lookup = lookupcache[0x0930]
- if lookup then
- local hit = lookup[0x094D]
- if hit then
- reph = hit["ligature"]
- end
+ if subset[3] then
+ reph = true
end
local current = start
local last = stop.next
@@ -1294,7 +1173,6 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
elseif kind == "pref" then
-- why not global? pretty ineffient this way
-- this will move to the initializer and we will store the hash in dataset
- -- todo: reph might also be result of chain
for k, v in lookupcache[0x094D], next do
pre_base_reordering_consonants[k] = v and v["ligature"] --ToDo: reph might also be result of chain
end
@@ -1328,15 +1206,15 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
local next = current.next
local n = locl[next] or next.char
if found[n] then
- if next ~= stop and next.next.char == c_zwnj then -- zwnj prevent creation of half
- current = next
+ if next ~= stop and next.next.char == c_zwnj then --ZWNJ prevent creation of half
+ current = current.next
else
current[a_state] = s_half
if not halfpos then
halfpos = current
end
end
- current = current.next
+ current = next
end
end
end
@@ -1397,40 +1275,38 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
current = start.next.next
end
- local function stand_alone(is_nbsp)
+ if current ~= stop.next and current.char == c_nbsp then
+ -- Stand Alone cluster
if current == stop then
stop = stop.prev
head = remove_node(head,current)
free_node(current)
- return head, stop, nbspaces
+ return head, stop
else
- if is_nbsp then
- nbspaces = nbspaces + 1
- end
- base = current
+ base = current
current = current.next
if current ~= stop then
local char = current.char
- if nukta[char] then
+ if char == c_nukta then
current = current.next
char = current.char
end
if char == c_zwj then
local next = current.next
- if current ~= stop and next ~= stop and halant[next.char] then
+ if current ~= stop and next ~= stop and next.char == c_halant then
current = next
next = current.next
local tmp = next.next
local changestop = next == stop
next.next = nil
current[a_state] = s_pref
- current = processcharacters(current,font)
+ current = processcharacters(current)
current[a_state] = s_blwf
- current = processcharacters(current,font)
+ current = processcharacters(current)
current[a_state] = s_pstf
- current = processcharacters(current,font)
+ current = processcharacters(current)
current[a_state] = unsetvalue
- if halant[current.char] then
+ if current.char == c_halant then
current.next.next = tmp
local nc = copy_node(current)
current.char = dotted_circle
@@ -1445,26 +1321,18 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
end
end
end
- end
-
- if current ~= stop.next then
- -- Stand Alone cluster
- stand_alone()
- elseif current.char == c_nbsp then
- -- Stand Alone cluster
- stand_alone(true)
else -- not Stand Alone cluster
local last = stop.next
while current ~= last do -- find base consonant
local next = current.next
if consonant[current.char] then
- if not (current ~= stop and next ~= stop and halant[next.char] and next.next.char == c_zwj) then
+ if not (current ~= stop and next ~= stop and next.char == c_halant and next.next.char == c_zwj) then
if not firstcons then
firstcons = current
end
-- check whether consonant has below-base or post-base form or is pre-base reordering Ra
local a = current[a_state]
- if not (a == s_pref or a == s_blwf or a == s_pstf) then
+ if not (a == s_pref or a == s_blwf or a == pstf) then
base = current
end
end
@@ -1480,7 +1348,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
if start[a_state] == s_rphf then
start[a_state] = unsetvalue
end
- return head, stop, nbspaces
+ return head, stop
else
if base[a_state] then
base[a_state] = unsetvalue
@@ -1582,7 +1450,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
local current, c = start, nil
while current ~= stop do
local char = current.char
- if halant[char] or stress_tone_mark[char] then
+ if char == c_halant or stress_tone_mark[char] then
if not c then
c = current
end
@@ -1590,7 +1458,7 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
c = nil
end
local next = current.next
- if c and nukta[next.char] then
+ if c and next.char == c_nukta then
if head == c then
head = next
end
@@ -1616,12 +1484,11 @@ local function dev2_reorder(head,start,stop,font,attr,nbspaces) -- maybe do a pa
end
if base.char == c_nbsp then
- nbspaces = nbspaces - 1
head = remove_node(head, base)
free_node(base)
end
- return head, stop, nbspaces
+ return head, stop
end
-- cleaned up and optimized ... needs checking (local, check order, fixes, extra hash, etc)
@@ -1634,8 +1501,8 @@ imerge(separator,dependent_vowel)
imerge(separator,vowel_modifier)
imerge(separator,stress_tone_mark)
-for k, v in next, nukta do separator[k] = true end
-for k, v in next, halant do separator[k] = true end
+separator[0x093C] = true -- nukta
+separator[0x094D] = true -- halant
local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowel
-- why two variants ... the comment suggests that it's the same ruleset
@@ -1645,7 +1512,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
if variant == 1 then
local v = n.id == glyph_code and n.subtype<256 and n.font == font
- if v and nukta[n.char] then
+ if v and n.char == c_nukta then
n = n.next
if n then
v = n.id == glyph_code and n.subtype<256 and n.font == font
@@ -1660,7 +1527,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
local nnnc = nnn.char
if nnc == c_zwj and consonant[nnnc] then
c = nnn
- elseif (nnc == c_zwnj or nnc == c_zwj) and halant[nnnc] then
+ elseif (nnc == c_zwnj or nnc == c_zwj) and nnnc == c_halant then
local nnnn = nnn.next
if nnnn and nnnn.id == glyph_code and consonant[nnnn.char] and nnnn.subtype<256 and nnnn.font == font then
c = nnnn
@@ -1670,7 +1537,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
end
elseif variant == 2 then
- if n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then
+ if n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then
c = n
end
n = c.next
@@ -1681,9 +1548,9 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
if nv and zw_char[n.char] then
n = nn
nn = nn.next
- nv = nn and nn.id == glyph_code and nn.subtype<256 and nn.font == font
+ nv = nn.id == glyph_code and nn.subtype<256 and nn.font == font
end
- if nv and halant[n.char] and consonant[nn.char] then
+ if nn and nv and n.char == c_halant and consonant[nn.char] then
c = nn
end
end
@@ -1711,7 +1578,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
char = n.char
end
- if nukta[char] then
+ if char == c_nukta then
c = c.next
n = c.next
if not n then
@@ -1723,7 +1590,7 @@ local function analyze_next_chars_one(c,font,variant) -- skip one dependent vowe
end
char = n.char
end
- if halant[char] then
+ if char == c_halant then
c = c.next
n = c.next
if not n then
@@ -1771,7 +1638,7 @@ local function analyze_next_chars_two(c,font)
if not n then
return c
end
- if n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then
+ if n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then
c = n
end
n = c
@@ -1779,7 +1646,7 @@ local function analyze_next_chars_two(c,font)
local nn = n.next
if nn and nn.id == glyph_code and nn.subtype<256 and nn.font == font then
local char = nn.char
- if halant[char] then
+ if char == c_halant then
n = nn
local nnn = nn.next
if nnn and nnn.id == glyph_code and zw_char[nnn.char] and nnn.subtype<256 and nnn.font == font then
@@ -1788,7 +1655,7 @@ local function analyze_next_chars_two(c,font)
elseif char == c_zwnj or char == c_zwj then
-- n = nn -- not here (?)
local nnn = nn.next
- if nnn and nnn.id == glyph_code and halant[nnn.char] and nnn.subtype<256 and nnn.font == font then
+ if nnn and nnn.id == glyph_code and nnn.char == c_halant and nnn.subtype<256 and nnn.font == font then
n = nnn
end
else
@@ -1798,7 +1665,7 @@ local function analyze_next_chars_two(c,font)
if nn and nn.id == glyph_code and consonant[nn.char] and nn.subtype<256 and nn.font == font then
n = nn
local nnn = nn.next
- if nnn and nnn.id == glyph_code and nukta[nnn.char] and nnn.subtype<256 and nnn.font == font then
+ if nnn and nnn.id == glyph_code and nnn.char == c_nukta and nnn.subtype<256 and nnn.font == font then
n = nnn
end
c = n
@@ -1835,7 +1702,7 @@ local function analyze_next_chars_two(c,font)
end
char = n.char
end
- if halant[char] then
+ if char == c_halant then
c = c.next
n = c.next
if not n then
@@ -1873,7 +1740,7 @@ local function analyze_next_chars_two(c,font)
end
char = n.char
end
- if nukta[char] then
+ if char == c_nukta then
c = c.next
n = c.next
if not n then
@@ -1885,7 +1752,7 @@ local function analyze_next_chars_two(c,font)
end
char = n.char
end
- if halant[char] then
+ if char == c_halant then
c = c.next
n = c.next
if not n then
@@ -1944,10 +1811,7 @@ end
-- a lot. Common code has been synced.
function methods.deva(head,font,attr)
- local current = head
- local start = true
- local done = false
- local nbspaces = 0
+ local current, start, done = head, true, false
while current do
if current.id == glyph_code and current.subtype<256 and current.font == font then
done = true
@@ -1955,7 +1819,7 @@ function methods.deva(head,font,attr)
local syllableend = nil
local c = current
local n = c.next
- if n and c.char == c_ra and n.id == glyph_code and halant[n.char] and n.subtype<256 and n.font == font then
+ if n and c.char == c_ra and n.id == glyph_code and n.char == c_halant and n.subtype<256 and n.font == font then
local n = n.next
if n and n.id == glyph_code and n.subtype<256 and n.font == font then
c = n
@@ -1976,10 +1840,9 @@ function methods.deva(head,font,attr)
end
if standalone then
-- stand alone cluster (at the start of the word only): #[Ra+H]+NBSP+[N]+[<[
]+H+C>]+[{M}+[N]+[H]]+[SM]+[(VD)]
- local syllableend = analyze_next_chars_one(c,font,2)
- current = syllableend.next
+ local syllabeend, current = analyze_next_chars_one(c,font,2) -- watch out, here we set current to next
if syllablestart ~= syllableend then
- head, current, nbspaces = deva_reorder(head,syllablestart,syllableend,font,attr,nbspaces)
+ head, current = deva_reorder(head,syllablestart,syllableend,font,attr)
current = current.next
end
else
@@ -2001,7 +1864,7 @@ function methods.deva(head,font,attr)
break
end
local c = n.char
- if nukta[c] then
+ if c == c_nukta then
n = n.next
if not n then
break
@@ -2012,7 +1875,7 @@ function methods.deva(head,font,attr)
end
c = n.char
end
- if halant[c] then
+ if c == c_halant then
n = n.next
if not n then
break
@@ -2040,7 +1903,7 @@ function methods.deva(head,font,attr)
end
end
local n = current.next
- if n and n.id == glyph_code and nukta[n.char] and n.subtype<256 and n.font == font then
+ if n and n.id == glyph_code and n.char == c_nukta and n.subtype<256 and n.font == font then
-- nukta (not specified in Microsft Devanagari OpenType specification)
current = n
n = current.next
@@ -2050,7 +1913,7 @@ function methods.deva(head,font,attr)
if current then
local v = current.id == glyph_code and current.subtype<256 and current.font == font
if v then
- if halant[current.char] then
+ if current.char == c_halant then
-- syllable containing consonant without vowels: {C + [Nukta] + H} + C + H
local n = current.next
if n and n.id == glyph_code and zw_char[n.char] and n.subtype<256 and n.font == font then
@@ -2088,7 +1951,7 @@ function methods.deva(head,font,attr)
end
end
if syllablestart ~= syllableend then
- head, current, nbspaces = deva_reorder(head,syllablestart,syllableend,font,attr,nbspaces)
+ head, current = deva_reorder(head,syllablestart,syllableend,font,attr)
current = current.next
end
elseif independent_vowel[char] then
@@ -2127,12 +1990,6 @@ function methods.deva(head,font,attr)
start = false
end
- if nbspaces > 0 then
- head = replace_all_nbsp(head)
- end
-
- head = typesetters.characters.handler(head)
-
return head, done
end
@@ -2142,11 +1999,10 @@ end
-- handler(head,start,kind,lookupname,lookupmatch,sequence,lookuphash,1)
function methods.dev2(head,font,attr)
- local current = head
- local start = true
- local done = false
- local syllabe = 0
- local nbspaces = 0
+ local current = head
+ local start = true
+ local done = false
+ local syllabe = 0
while current do
local syllablestart, syllableend = nil, nil
if current.id == glyph_code and current.subtype<256 and current.font == font then
@@ -2154,7 +2010,7 @@ function methods.dev2(head,font,attr)
syllablestart = current
local c = current
local n = current.next
- if n and c.char == c_ra and n.id == glyph_code and halant[n.char] and n.subtype<256 and n.font == font then
+ if n and c.char == c_ra and n.id == glyph_code and n.char == c_halant and n.subtype<256 and n.font == font then
local n = n.next
if n and n.id == glyph_code and n.subtype<256 and n.font == font then
c = n
@@ -2168,7 +2024,6 @@ function methods.dev2(head,font,attr)
else
local standalone = char == c_nbsp
if standalone then
- nbspaces = nbspaces + 1
local p = current.prev
if not p then
-- begin of paragraph or box
@@ -2203,7 +2058,7 @@ function methods.dev2(head,font,attr)
end
end
if syllableend and syllablestart ~= syllableend then
- head, current, nbspaces = dev2_reorder(head,syllablestart,syllableend,font,attr,nbspaces)
+ head, current = dev2_reorder(head,syllablestart,syllableend,font,attr)
end
if not syllableend and current.id == glyph_code and current.subtype<256 and current.font == font and not current[a_state] then
local mark = mark_four[current.char]
@@ -2215,9 +2070,5 @@ function methods.dev2(head,font,attr)
current = current.next
end
- if nbspaces > 0 then
- head = replace_all_nbsp(head)
- end
-
return head, done
end
diff --git a/tex/context/base/font-ota.lua b/tex/context/base/font-ota.lua
index 9af5a3347..79fcf3fa2 100644
--- a/tex/context/base/font-ota.lua
+++ b/tex/context/base/font-ota.lua
@@ -32,7 +32,6 @@ local a_state = attributes.private('state')
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
local math_code = nodecodes.math
local traverse_id = node.traverse_id
@@ -79,12 +78,6 @@ local features = {
fina = 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,
}
analyzers.states = states
@@ -125,7 +118,7 @@ function analyzers.setstate(head,font)
end
elseif id == disc_code then
-- always in the middle
- current[a_state] = s_medi
+ current[a_state] = s_midi
last = current
else -- finish
if first and first == last then
@@ -186,7 +179,7 @@ end
registerotffeature {
name = "analyze",
- description = "analysis of character classes",
+ description = "analysis of (for instance) character classes",
default = true,
initializers = {
node = analyzeinitializer,
diff --git a/tex/context/base/font-otc.lua b/tex/context/base/font-otc.lua
index 3006e47ca..a87dcadf8 100644
--- a/tex/context/base/font-otc.lua
+++ b/tex/context/base/font-otc.lua
@@ -188,11 +188,9 @@ otf.enhancers.register("check extra features",enhance)
-- tlig --
-local tlig = { -- we need numbers for some fonts so ...
- -- endash = "hyphen hyphen",
- -- emdash = "hyphen hyphen hyphen",
- [0x2013] = { 0x002D, 0x002D },
- [0x2014] = { 0x002D, 0x002D, 0x002D },
+local tlig = {
+ endash = "hyphen hyphen",
+ emdash = "hyphen hyphen hyphen",
-- quotedblleft = "quoteleft quoteleft",
-- quotedblright = "quoteright quoteright",
-- quotedblleft = "grave grave",
diff --git a/tex/context/base/font-otd.lua b/tex/context/base/font-otd.lua
index 919da2379..a9d093d6d 100644
--- a/tex/context/base/font-otd.lua
+++ b/tex/context/base/font-otd.lua
@@ -242,19 +242,19 @@ function otf.dataset(tfmdata,font,attr) -- attr only when explicit (as in specia
}
rl[attr] = ra
local sequences = tfmdata.resources.sequences
- -- setmetatableindex(ra, function(t,k)
- -- if type(k) == "number" then
- -- local v = initialize(sequences[k],script,language,s_enabled,a_enabled,font,attr,dynamic)
- -- t[k] = v or false
- -- return v
- -- end
- -- end)
- for s=1,#sequences do
- local v = initialize(sequences[s],script,language,s_enabled,a_enabled,font,attr,dynamic)
- if v then
- ra[#ra+1] = v
- end
- end
+-- setmetatableindex(ra, function(t,k)
+-- if type(k) == "number" then
+-- local v = initialize(sequences[k],script,language,s_enabled,a_enabled,font,attr,dynamic)
+-- t[k] = v or false
+-- return v
+-- end
+-- end)
+for s=1,#sequences do
+ local v = initialize(sequences[s],script,language,s_enabled,a_enabled,font,attr,dynamic)
+ if v then
+ ra[#ra+1] = v
+ end
+end
end
return ra
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 7598a9c35..c1f2f14fc 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -48,7 +48,7 @@ local otf = fonts.handlers.otf
otf.glists = { "gsub", "gpos" }
-otf.version = 2.745 -- beware: also sync font-mis.lua
+otf.version = 2.743 -- beware: also sync font-mis.lua
otf.cache = containers.define("fonts", "otf", otf.version, true)
local fontdata = fonts.hashes.identifiers
@@ -73,9 +73,6 @@ local packdata = true
local syncspace = true
local forcenotdef = false
local includesubfonts = false
-local overloadkerns = false -- experiment
-
-local applyruntimefixes = fonts.treatments and fonts.treatments.applyfixes
local wildcard = "*"
local default = "dflt"
@@ -84,24 +81,12 @@ local fontloaderfields = fontloader.fields
local mainfields = nil
local glyphfields = nil -- not used yet
-local formats = fonts.formats
-
-formats.otf = "opentype"
-formats.ttf = "truetype"
-formats.ttc = "truetype"
-formats.dfont = "truetype"
-
registerdirective("fonts.otf.loader.cleanup", function(v) cleanup = tonumber(v) or (v and 1) or 0 end)
registerdirective("fonts.otf.loader.force", function(v) forceload = v end)
registerdirective("fonts.otf.loader.usemetatables", function(v) usemetatables = v end)
registerdirective("fonts.otf.loader.pack", function(v) packdata = v end)
registerdirective("fonts.otf.loader.syncspace", function(v) syncspace = v end)
registerdirective("fonts.otf.loader.forcenotdef", function(v) forcenotdef = v end)
-registerdirective("fonts.otf.loader.overloadkerns", function(v) overloadkerns = v end)
-
-local function otf_format(filename)
- return formats[lower(file.suffix(filename))]
-end
local function load_featurefile(raw,featurefile)
if featurefile and featurefile ~= "" then
@@ -336,7 +321,7 @@ function enhancers.register(what,action) -- only already registered can be overl
actions[what] = action
end
-function otf.load(filename,sub,featurefile) -- second argument (format) is gone !
+function otf.load(filename,format,sub,featurefile)
local base = file.basename(file.removesuffix(filename))
local name = file.removesuffix(base)
local attr = lfs.attributes(filename)
@@ -435,7 +420,7 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone
data = {
size = size,
time = time,
- format = otf_format(filename),
+ format = format,
featuredata = featurefiles,
resources = {
filename = resolvers.unresolve(filename), -- no shortcut
@@ -509,9 +494,6 @@ function otf.load(filename,sub,featurefile) -- second argument (format) is gone
report_otf("loading from cache using hash %a",hash)
end
enhance("unpack",data,filename,nil,false)
- if applyruntimefixes then
- applyruntimefixes(filename,data)
- end
enhance("add dimensions",data,filename,nil,false)
if trace_sequences then
showfeatureorder(data,filename)
@@ -1552,118 +1534,6 @@ actions["reorganize glyph kerns"] = function(data,filename,raw)
end
end
--- actions["merge kern classes"] = function(data,filename,raw)
--- local gposlist = raw.gpos
--- if gposlist then
--- local descriptions = data.descriptions
--- local resources = data.resources
--- local unicodes = resources.unicodes
--- local splitter = data.helpers.tounicodetable
--- local ignored = 0
--- for gp=1,#gposlist do
--- local gpos = gposlist[gp]
--- local subtables = gpos.subtables
--- if subtables then
--- for s=1,#subtables do
--- local subtable = subtables[s]
--- local kernclass = subtable.kernclass -- name is inconsistent with anchor_classes
--- if kernclass then -- the next one is quite slow
--- local split = { } -- saves time
--- for k=1,#kernclass do
--- local kcl = kernclass[k]
--- local firsts = kcl.firsts
--- local seconds = kcl.seconds
--- local offsets = kcl.offsets
--- local lookups = kcl.lookup -- singular
--- if type(lookups) ~= "table" then
--- lookups = { lookups }
--- end
--- -- if offsets[1] == nil then
--- -- offsets[1] = "" -- defaults ?
--- -- end
--- -- we can check the max in the loop
--- -- local maxseconds = getn(seconds)
--- for n, s in next, firsts do
--- split[s] = split[s] or lpegmatch(splitter,s)
--- end
--- local maxseconds = 0
--- for n, s in next, seconds do
--- if n > maxseconds then
--- maxseconds = n
--- end
--- split[s] = split[s] or lpegmatch(splitter,s)
--- end
--- for l=1,#lookups do
--- local lookup = lookups[l]
--- for fk=1,#firsts do -- maxfirsts ?
--- local fv = firsts[fk]
--- local splt = split[fv]
--- if splt then
--- local extrakerns = { }
--- local baseoffset = (fk-1) * maxseconds
--- for sk=2,maxseconds do -- will become 1 based in future luatex
--- local sv = seconds[sk]
--- -- for sk, sv in next, seconds do
--- local splt = split[sv]
--- if splt then -- redundant test
--- local offset = offsets[baseoffset + sk]
--- if offset then
--- for i=1,#splt do
--- extrakerns[splt[i]] = offset
--- end
--- end
--- end
--- end
--- for i=1,#splt do
--- local first_unicode = splt[i]
--- local description = descriptions[first_unicode]
--- if description then
--- local kerns = description.kerns
--- if not kerns then
--- kerns = { } -- unicode indexed !
--- description.kerns = kerns
--- end
--- local lookupkerns = kerns[lookup]
--- if not lookupkerns then
--- lookupkerns = { }
--- kerns[lookup] = lookupkerns
--- end
--- if overloadkerns then
--- for second_unicode, kern in next, extrakerns do
--- lookupkerns[second_unicode] = kern
--- end
--- else
--- for second_unicode, kern in next, extrakerns do
--- local k = lookupkerns[second_unicode]
--- if not k then
--- lookupkerns[second_unicode] = kern
--- elseif k ~= kern then
--- if trace_loading then
--- report_otf("lookup %a: ignoring overload of kern between %C and %C, rejecting %a, keeping %a",lookup,first_unicode,second_unicode,k,kern)
--- end
--- ignored = ignored + 1
--- end
--- end
--- end
--- elseif trace_loading then
--- report_otf("no glyph data for %U", first_unicode)
--- end
--- end
--- end
--- end
--- end
--- end
--- subtable.kernclass = { }
--- end
--- end
--- end
--- end
--- if ignored > 0 then
--- report_otf("%s kern overloads ignored")
--- end
--- end
--- end
-
actions["merge kern classes"] = function(data,filename,raw)
local gposlist = raw.gpos
if gposlist then
@@ -1671,99 +1541,80 @@ actions["merge kern classes"] = function(data,filename,raw)
local resources = data.resources
local unicodes = resources.unicodes
local splitter = data.helpers.tounicodetable
- local ignored = 0
- local blocked = 0
for gp=1,#gposlist do
local gpos = gposlist[gp]
local subtables = gpos.subtables
if subtables then
- local first_done = { } -- could become an option so that we can deal with buggy fonts that don't get fixed
- local split = { } -- saves time .. although probably not that much any more in the fixed luatex kernclass table
for s=1,#subtables do
local subtable = subtables[s]
local kernclass = subtable.kernclass -- name is inconsistent with anchor_classes
- local lookup = subtable.lookup or subtable.name
if kernclass then -- the next one is quite slow
- if #kernclass > 0 then
- kernclass = kernclass[1]
- lookup = type(kernclass.lookup) == "string" and kernclass.lookup or lookup
- report_otf("fixing kernclass table of lookup %a",lookup)
- end
- local firsts = kernclass.firsts
- local seconds = kernclass.seconds
- local offsets = kernclass.offsets
- -- if offsets[1] == nil then
- -- offsets[1] = "" -- defaults ?
- -- end
- -- we can check the max in the loop
- -- local maxseconds = getn(seconds)
- for n, s in next, firsts do
- split[s] = split[s] or lpegmatch(splitter,s)
- end
- local maxseconds = 0
- for n, s in next, seconds do
- if n > maxseconds then
- maxseconds = n
+ local split = { } -- saves time
+ for k=1,#kernclass do
+ local kcl = kernclass[k]
+ local firsts = kcl.firsts
+ local seconds = kcl.seconds
+ local offsets = kcl.offsets
+ local lookups = kcl.lookup -- singular
+ if type(lookups) ~= "table" then
+ lookups = { lookups }
end
- split[s] = split[s] or lpegmatch(splitter,s)
- end
- for fk=1,#firsts do -- maxfirsts ?
- local fv = firsts[fk]
- local splt = split[fv]
- if splt then
- local extrakerns = { }
- local baseoffset = (fk-1) * maxseconds
- for sk=2,maxseconds do -- will become 1 based in future luatex
- local sv = seconds[sk]
- -- for sk, sv in next, seconds do
- local splt = split[sv]
- if splt then -- redundant test
- local offset = offsets[baseoffset + sk]
- if offset then
- for i=1,#splt do
- extrakerns[splt[i]] = offset
- end
- end
- end
+ -- if offsets[1] == nil then
+ -- offsets[1] = ""
+ -- end
+ -- we can check the max in the loop
+ -- local maxseconds = getn(seconds)
+ for n, s in next, firsts do
+ split[s] = split[s] or lpegmatch(splitter,s)
+ end
+ local maxseconds = 0
+ for n, s in next, seconds do
+ if n > maxseconds then
+ maxseconds = n
end
- for i=1,#splt do
- local first_unicode = splt[i]
- if first_done[first_unicode] then
- report_otf("lookup %a: ignoring further kerns of %C",lookup,first_unicode)
- blocked = blocked + 1
- else
- first_done[first_unicode] = true
- local description = descriptions[first_unicode]
- if description then
- local kerns = description.kerns
- if not kerns then
- kerns = { } -- unicode indexed !
- description.kerns = kerns
- end
- local lookupkerns = kerns[lookup]
- if not lookupkerns then
- lookupkerns = { }
- kerns[lookup] = lookupkerns
+ split[s] = split[s] or lpegmatch(splitter,s)
+ end
+ for l=1,#lookups do
+ local lookup = lookups[l]
+ for fk=1,#firsts do -- maxfirsts ?
+ local fv = firsts[fk]
+ local splt = split[fv]
+ if splt then
+ local extrakerns = { }
+ local baseoffset = (fk-1) * maxseconds
+ for sk=2,maxseconds do -- will become 1 based in future luatex
+ local sv = seconds[sk]
+ -- for sk, sv in next, seconds do
+ local splt = split[sv]
+ if splt then -- redundant test
+ local offset = offsets[baseoffset + sk]
+ if offset then
+ for i=1,#splt do
+ extrakerns[splt[i]] = offset
+ end
+ end
end
- if overloadkerns then
- for second_unicode, kern in next, extrakerns do
- lookupkerns[second_unicode] = kern
+ end
+ for i=1,#splt do
+ local first_unicode = splt[i]
+ local description = descriptions[first_unicode]
+ if description then
+ local kerns = description.kerns
+ if not kerns then
+ kerns = { } -- unicode indexed !
+ description.kerns = kerns
+ end
+ local lookupkerns = kerns[lookup]
+ if not lookupkerns then
+ lookupkerns = { }
+ kerns[lookup] = lookupkerns
end
- else
for second_unicode, kern in next, extrakerns do
- local k = lookupkerns[second_unicode]
- if not k then
- lookupkerns[second_unicode] = kern
- elseif k ~= kern then
- if trace_loading then
- report_otf("lookup %a: ignoring overload of kern between %C and %C, rejecting %a, keeping %a",lookup,first_unicode,second_unicode,k,kern)
- end
- ignored = ignored + 1
- end
+ lookupkerns[second_unicode] = kern
end
+ elseif trace_loading then
+ report_otf("no glyph data for %U", first_unicode)
end
- elseif trace_loading then
- report_otf("no glyph data for %U", first_unicode)
end
end
end
@@ -1774,12 +1625,6 @@ actions["merge kern classes"] = function(data,filename,raw)
end
end
end
- if ignored > 0 then
- report_otf("%s kern overloads ignored",ignored)
- end
- if blocked > 0 then
- report_otf("%s succesive kerns blocked",blocked)
- end
end
end
@@ -2049,24 +1894,10 @@ local function copytotfm(data,cache_id)
end
end
-- end math
- -- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't we use the basename then?)
- local filename = constructors.checkedfilename(resources)
- local fontname = metadata.fontname
- local fullname = metadata.fullname or fontname
- local units = metadata.units_per_em or 1000
- --
- if units == 0 then -- catch bugs in fonts
- units = 1000 -- maybe 2000 when ttf
- metadata.units_per_em = 1000
- report_otf("changing %a units to %a",0,units)
- end
- --
local monospaced = metadata.isfixedpitch or (pfminfo.panose and pfminfo.panose.proportion == "Monospaced")
local charwidth = pfminfo.avgwidth -- or unset
- local charxheight = pfminfo.os2_xheight and pfminfo.os2_xheight > 0 and pfminfo.os2_xheight
--- charwidth = charwidth * units/1000
--- charxheight = charxheight * units/1000
local italicangle = metadata.italicangle
+ local charxheight = pfminfo.os2_xheight and pfminfo.os2_xheight > 0 and pfminfo.os2_xheight
properties.monospaced = monospaced
parameters.italicangle = italicangle
parameters.charwidth = charwidth
@@ -2096,6 +1927,16 @@ local function copytotfm(data,cache_id)
end
end
spaceunits = tonumber(spaceunits) or 500 -- brrr
+ -- we need a runtime lookup because of running from cdrom or zip, brrr (shouldn't we use the basename then?)
+ local filename = constructors.checkedfilename(resources)
+ local fontname = metadata.fontname
+ local fullname = metadata.fullname or fontname
+ local units = metadata.units_per_em or 1000
+ --
+ if units == 0 then -- catch bugs in fonts
+ units = 1000
+ metadata.units_per_em = 1000
+ end
--
parameters.slant = 0
parameters.space = spaceunits -- 3.333 (cmr10)
@@ -2106,10 +1947,10 @@ local function copytotfm(data,cache_id)
if spaceunits < 2*units/5 then
-- todo: warning
end
- if italicangle and italicangle ~= 0 then
+ if italicangle then
parameters.italicangle = italicangle
parameters.italicfactor = math.cos(math.rad(90+italicangle))
- parameters.slant = - math.tan(italicangle*math.pi/180)
+ parameters.slant = - math.round(math.tan(italicangle*math.pi/180))
end
if monospaced then
parameters.space_stretch = 0
@@ -2138,7 +1979,7 @@ local function copytotfm(data,cache_id)
--
properties.space = spacer
properties.encodingbytes = 2
- properties.format = data.format or otf_format(filename) or formats.otf
+ properties.format = data.format or fonts.formats[filename] or "opentype"
properties.noglyphnames = true
properties.filename = filename
properties.fontname = fontname
@@ -2167,9 +2008,9 @@ local function otftotfm(specification)
local name = specification.name
local sub = specification.sub
local filename = specification.filename
- -- local format = specification.format
+ local format = specification.format
local features = specification.features.normal
- local rawdata = otf.load(filename,sub,features and features.featurefile)
+ local rawdata = otf.load(filename,format,sub,features and features.featurefile)
if rawdata and next(rawdata) then
rawdata.lookuphash = { }
tfmdata = copytotfm(rawdata,cache_id)
@@ -2263,38 +2104,48 @@ function otf.collectlookups(rawdata,kind,script,language)
return nil, nil
end
--- readers (a bit messy, this forced so I might redo that bit: foo.ttf FOO.ttf foo.TTF FOO.TTF)
+-- readers
-local function check_otf(forced,specification,suffix)
+local function check_otf(forced,specification,suffix,what)
local name = specification.name
if forced then
- name = specification.forcedname -- messy
+ name = file.addsuffix(name,suffix,true)
end
local fullname = findbinfile(name,suffix) or ""
if fullname == "" then
fullname = fonts.names.getfilename(name,suffix) or ""
end
- if fullname ~= "" and not fonts.names.ignoredfile(fullname) then
+ if fullname ~= "" then
specification.filename = fullname
+ specification.format = what
return read_from_otf(specification)
end
end
-local function opentypereader(specification,suffix)
+local function opentypereader(specification,suffix,what)
local forced = specification.forced or ""
- if formats[forced] then
- return check_otf(true,specification,forced)
+ if forced == "otf" then
+ return check_otf(true,specification,forced,"opentype")
+ elseif forced == "ttf" or forced == "ttc" or forced == "dfont" then
+ return check_otf(true,specification,forced,"truetype")
else
- return check_otf(false,specification,suffix)
+ return check_otf(false,specification,suffix,what)
end
end
-readers.opentype = opentypereader -- kind of useless and obsolete
+readers.opentype = opentypereader
+
+local formats = fonts.formats
+
+formats.otf = "opentype"
+formats.ttf = "truetype"
+formats.ttc = "truetype"
+formats.dfont = "truetype"
-function readers.otf (specification) return opentypereader(specification,"otf") end
-function readers.ttf (specification) return opentypereader(specification,"ttf") end
-function readers.ttc (specification) return opentypereader(specification,"ttf") end
-function readers.dfont(specification) return opentypereader(specification,"ttf") end
+function readers.otf (specification) return opentypereader(specification,"otf",formats.otf ) end
+function readers.ttf (specification) return opentypereader(specification,"ttf",formats.ttf ) end
+function readers.ttc (specification) return opentypereader(specification,"ttf",formats.ttc ) end
+function readers.dfont(specification) return opentypereader(specification,"ttf",formats.dfont) end
-- this will be overloaded
diff --git a/tex/context/base/font-otn.lua b/tex/context/base/font-otn.lua
index 3733d51c2..5da0cf798 100644
--- a/tex/context/base/font-otn.lua
+++ b/tex/context/base/font-otn.lua
@@ -20,7 +20,7 @@ if not modules then modules = { } end modules ['font-otn'] = {
-- todo:
--
--- kerning is probably not yet ok for latin around dics nodes (interesting challenge)
+-- kerning is probably not yet ok for latin around dics nodes
-- extension infrastructure (for usage out of context)
-- sorting features according to vendors/renderers
-- alternative loop quitters
@@ -31,8 +31,7 @@ if not modules then modules = { } end modules ['font-otn'] = {
-- handle gpos_single (we might want an extra width field in glyph nodes because adding kerns might interfere)
-- mark (to mark) code is still not what it should be (too messy but we need some more extreem husayni tests)
-- remove some optimizations (when I have a faster machine)
---
--- maybe redo the lot some way (more context specific)
+
--[[ldx--
This module is a bit more split up that I'd like but since we also want to test
@@ -188,7 +187,6 @@ local default = "dflt"
local nodecodes = nodes.nodecodes
local whatcodes = nodes.whatcodes
local glyphcodes = nodes.glyphcodes
-local disccodes = nodes.disccodes
local glyph_code = nodecodes.glyph
local glue_code = nodecodes.glue
@@ -199,8 +197,6 @@ local math_code = nodecodes.math
local dir_code = whatcodes.dir
local localpar_code = whatcodes.localpar
-local discretionary_code = disccodes.discretionary
-
local ligature_code = glyphcodes.ligature
local privateattribute = attributes.private
@@ -506,18 +502,13 @@ local function get_alternative_glyph(start,alternatives,value,trace_alternatives
end
end
-local function multiple_glyphs(head,start,multiple,ignoremarks)
+local function multiple_glyphs(head,start,multiple) -- marks ?
local nofmultiples = #multiple
if nofmultiples > 0 then
start.char = multiple[1]
if nofmultiples > 1 then
local sn = start.next
for k=2,nofmultiples do -- todo: use insert_node
--- untested:
---
--- while ignoremarks and marks[sn.char] then
--- local sn = sn.next
--- end
local n = copy_node(start) -- ignore components
n.char = multiple[k]
n.next = sn
@@ -539,7 +530,7 @@ local function multiple_glyphs(head,start,multiple,ignoremarks)
end
function handlers.gsub_alternate(head,start,kind,lookupname,alternative,sequence)
- local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
+ local value = featurevalue == true and tfmdata.shared.features[kind] or featurevalue
local choice, comment = get_alternative_glyph(start,alternative,value,trace_alternatives)
if choice then
if trace_alternatives then
@@ -554,11 +545,11 @@ function handlers.gsub_alternate(head,start,kind,lookupname,alternative,sequence
return head, start, true
end
-function handlers.gsub_multiple(head,start,kind,lookupname,multiple,sequence)
+function handlers.gsub_multiple(head,start,kind,lookupname,multiple)
if trace_multiples then
logprocess("%s: replacing %s by multiple %s",pref(kind,lookupname),gref(start.char),gref(multiple))
end
- return multiple_glyphs(head,start,multiple,sequence.flags[1])
+ return multiple_glyphs(head,start,multiple)
end
function handlers.gsub_ligature(head,start,kind,lookupname,ligature,sequence)
@@ -657,7 +648,7 @@ function handlers.gpos_mark2base(head,start,kind,lookupname,markanchors,sequence
if marks[basechar] then
while true do
base = base.prev
- if base and base.id == glyph_code and base.font == currentfont and base.subtype<256 then
+ if base and base.id == glyph_code and base.font == currentfont and base.subtype<256 then
basechar = base.char
if not marks[basechar] then
break
@@ -805,7 +796,7 @@ function handlers.gpos_mark2mark(head,start,kind,lookupname,markanchors,sequence
if al[anchor] then
local ma = markanchors[anchor]
if ma then
- local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,true)
+ local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma)
if trace_marks then
logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%p,%p)",
pref(kind,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy)
@@ -914,6 +905,7 @@ function handlers.gpos_pair(head,start,kind,lookupname,kerns,sequence)
prev = snext
snext = snext.next
else
+ local krn = kerns[nextchar]
if not krn then
-- skip
elseif type(krn) == "table" then
@@ -1034,35 +1026,35 @@ single lookup case. The efficiency of the replacements can be improved by deleti
as less as needed but that would also make the code even more messy.
--ldx]]--
--- local function delete_till_stop(head,start,stop,ignoremarks) -- keeps start
--- local n = 1
--- if start == stop then
--- -- done
--- elseif ignoremarks then
--- repeat -- start x x m x x stop => start m
--- local next = start.next
--- if not marks[next.char] then
--- local components = next.components
--- if components then -- probably not needed
--- flush_node_list(components)
--- end
--- head = delete_node(head,next)
--- end
--- n = n + 1
--- until next == stop
--- else -- start x x x stop => start
--- repeat
--- local next = start.next
--- local components = next.components
--- if components then -- probably not needed
--- flush_node_list(components)
--- end
--- head = delete_node(head,next)
--- n = n + 1
--- until next == stop
--- end
--- return head, n
--- end
+local function delete_till_stop(start,stop,ignoremarks) -- keeps start
+ local n = 1
+ if start == stop then
+ -- done
+ elseif ignoremarks then
+ repeat -- start x x m x x stop => start m
+ local next = start.next
+ if not marks[next.char] then
+ local components = next.components
+ if components then -- probably not needed
+ flush_node_list(components)
+ end
+ delete_node(start,next)
+ end
+ n = n + 1
+ until next == stop
+ else -- start x x x stop => start
+ repeat
+ local next = start.next
+ local components = next.components
+ if components then -- probably not needed
+ flush_node_list(components)
+ end
+ delete_node(start,next)
+ n = n + 1
+ until next == stop
+ end
+ return n
+end
--[[ldx--
Here we replace start by a single variant, First we delete the rest of the
@@ -1116,7 +1108,7 @@ the match.
--ldx]]--
function chainprocs.gsub_multiple(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname)
- -- local head, n = delete_till_stop(head,start,stop)
+ delete_till_stop(start,stop) -- we could pass ignoremarks as #3 ..
local startchar = start.char
local subtables = currentlookup.subtables
local lookupname = subtables[1]
@@ -1135,7 +1127,7 @@ function chainprocs.gsub_multiple(head,start,stop,kind,chainname,currentcontext,
if trace_multiples then
logprocess("%s: replacing %s by multiple characters %s",cref(kind,chainname,chainlookupname,lookupname),gref(startchar),gref(replacements))
end
- return multiple_glyphs(head,start,replacements,currentlookup.flags[1])
+ return multiple_glyphs(head,start,replacements)
end
end
return head, start, false
@@ -1446,7 +1438,7 @@ function chainprocs.gpos_mark2mark(head,start,stop,kind,chainname,currentcontext
if al[anchor] then
local ma = markanchors[anchor]
if ma then
- local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma,true)
+ local dx, dy, bound = setmark(start,base,tfmdata.parameters.factor,rlmode,ba,ma)
if trace_marks then
logprocess("%s, anchor %s, bound %s: anchoring mark %s to basemark %s => (%p,%p)",
cref(kind,chainname,chainlookupname,lookupname),anchor,bound,gref(markchar),gref(basechar),dx,dy)
@@ -1558,11 +1550,10 @@ function chainprocs.gpos_single(head,start,stop,kind,chainname,currentcontext,lo
return head, start, false
end
-chainmores.gpos_single = chainprocs.gpos_single -- okay?
-
-- when machines become faster i will make a shared function
function chainprocs.gpos_pair(head,start,stop,kind,chainname,currentcontext,lookuphash,currentlookup,chainlookupname,chainindex,sequence)
+-- logwarning("%s: gpos_pair not yet supported",cref(kind,chainname,chainlookupname))
local snext = start.next
if snext then
local startchar = start.char
@@ -1632,8 +1623,6 @@ function chainprocs.gpos_pair(head,start,stop,kind,chainname,currentcontext,look
return head, start, false
end
-chainmores.gpos_pair = chainprocs.gpos_pair -- okay?
-
-- what pointer to return, spec says stop
-- to be discussed ... is bidi changer a space?
-- elseif char == zwnj and sequence[n][32] then -- brrr
@@ -1876,11 +1865,7 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
if chainlookup then
local cp = chainprocs[chainlookup.type]
if cp then
- local ok
- head, start, ok = cp(head,start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
- if ok then
- done = true
- end
+ head, start, done = cp(head,start,last,kind,chainname,ck,lookuphash,chainlookup,chainlookupname,nil,sequence)
else
logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
end
@@ -1907,28 +1892,22 @@ local function normal_handle_contextchain(head,start,kind,chainname,contexts,seq
end
end
local chainlookupname = chainlookups[i]
- local chainlookup = lookuptable[chainlookupname]
- if not chainlookup then
- -- okay, n matches, < n replacements
- i = i + 1
- else
- local cp = chainmores[chainlookup.type]
- if not cp then
- -- actually an error
- logprocess("%s: %s is not yet supported",cref(kind,chainname,chainlookupname),chainlookup.type)
- i = i + 1
+ local chainlookup = lookuptable[chainlookupname] -- can be false (n matches, 254
---
--- attr = attr or false
---
--- local a = getattr(start,0)
--- if (a == attr and (not attribute or getattr(start,a_state) == attribute)) or (not attribute or getattr(start,a_state) == attribute) then
--- -- the action
--- end
-
local function featuresprocessor(head,font,attr)
local lookuphash = lookuphashes[font] -- we can also check sequences here
@@ -2123,24 +2093,24 @@ local function featuresprocessor(head,font,attr)
checkstep(head)
end
- tfmdata = fontdata[font]
- descriptions = tfmdata.descriptions
- characters = tfmdata.characters
- resources = tfmdata.resources
+ tfmdata = fontdata[font]
+ descriptions = tfmdata.descriptions
+ characters = tfmdata.characters
+ resources = tfmdata.resources
- marks = resources.marks
- anchorlookups = resources.lookup_to_anchor
- lookuptable = resources.lookups
- lookuptypes = resources.lookuptypes
+ marks = resources.marks
+ anchorlookups = resources.lookup_to_anchor
+ lookuptable = resources.lookups
+ lookuptypes = resources.lookuptypes
- currentfont = font
- rlmode = 0
+ currentfont = font
+ rlmode = 0
- local sequences = resources.sequences
- local done = false
- local datasets = otf.dataset(tfmdata,font,attr)
+ local sequences = resources.sequences
+ local done = false
+ local datasets = otf.dataset(tfmdata,font,attr)
- local dirstack = { } -- could move outside function
+ local dirstack = { } -- could move outside function
-- 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
@@ -2150,360 +2120,245 @@ local function featuresprocessor(head,font,attr)
-- Keeping track of the headnode is needed for devanagari (I generalized it a bit
-- so that multiple cases are also covered.)
- for s=1,#datasets do
- local dataset = datasets[s]
- featurevalue = dataset[1] -- todo: pass to function instead of using a global
-
- local sequence = dataset[5] -- sequences[s] -- also dataset[5]
- local rlparmode = 0
- local topstack = 0
- local success = false
- local attribute = dataset[2]
- local chain = dataset[3] -- sequence.chain or 0
- local typ = sequence.type
- local subtables = sequence.subtables
- if chain < 0 then
- -- this is a limited case, no special treatments like 'init' etc
- local handler = handlers[typ]
- -- we need to get rid of this slide! probably no longer needed in latest luatex
- local start = find_node_tail(head) -- slow (we can store tail because there's always a skip at the end): todo
- while start do
- local id = start.id
- if id == glyph_code then
- if start.font == font and start.subtype<256 then
- local a = start[0]
- if a then
- a = a == attr
- else
- a = true
- end
- if a then
- for i=1,#subtables do
- local lookupname = subtables[i]
- local lookupcache = lookuphash[lookupname]
- if lookupcache then
- local lookupmatch = lookupcache[start.char]
- if lookupmatch then
- head, start, success = handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i)
- if success then
- break
- end
- end
- else
- report_missing_cache(typ,lookupname)
- end
- end
- if start then start = start.prev end
- else
- start = start.prev
- end
- else
- start = start.prev
- end
- else
- start = start.prev
- end
- end
- else
- local handler = handlers[typ]
- local ns = #subtables
- local start = head -- local ?
- rlmode = 0 -- to be checked ?
- if ns == 1 then -- happens often
- local lookupname = subtables[1]
- local lookupcache = lookuphash[lookupname]
- if not lookupcache then -- also check for empty cache
- report_missing_cache(typ,lookupname)
- else
-
- local function subrun(start)
- -- mostly for gsub, gpos would demand a more clever approach
- local head = start
- local done = false
- while start do
- local id = start.id
- if id == glyph_code and start.font == font and start.subtype <256 then
- local a = start[0]
- if a then
- a = (a == attr) and (not attribute or start[a_state] == attribute)
- else
- a = not attribute or start[a_state] == attribute
- end
- if a then
- local lookupmatch = lookupcache[start.char]
- if lookupmatch then
- -- sequence kan weg
- local ok
- head, start, ok = handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1)
- if ok then
- done = true
- end
- end
- if start then start = start.next end
- else
- start = start.next
- end
- else
- start = start.next
- end
- end
- if done then
- success = true
- return head
- end
- end
-
+-- for s=1,#sequences do
+-- local dataset = datasets[s]
+-- if dataset then
+-- featurevalue = dataset[1] -- todo: pass to function instead of using a global
+-- if featurevalue then -- never false
+
+for s=1,#datasets do
+ local dataset = datasets[s]
+ featurevalue = dataset[1] -- todo: pass to function instead of using a global
+
+ local sequence = dataset[5] -- sequences[s] -- also dataset[5]
+ local rlparmode = 0
+ local topstack = 0
+ local success = false
+ local attribute = dataset[2]
+ local chain = dataset[3] -- sequence.chain or 0
+ local typ = sequence.type
+ local subtables = sequence.subtables
+ if chain < 0 then
+ -- this is a limited case, no special treatments like 'init' etc
+ local handler = handlers[typ]
+ -- we need to get rid of this slide! probably no longer needed in latest luatex
+ local start = find_node_tail(head) -- slow (we can store tail because there's always a skip at the end): todo
while start do
local id = start.id
if id == glyph_code then
if start.font == font and start.subtype<256 then
local a = start[0]
if a then
- a = (a == attr) and (not attribute or start[a_state] == attribute)
+ a = a == attr
else
- a = not attribute or start[a_state] == attribute
+ a = true
end
if a then
- local lookupmatch = lookupcache[start.char]
- if lookupmatch then
- -- sequence kan weg
- local ok
- head, start, ok = handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1)
- if ok then
- success = true
+ for i=1,#subtables do
+ local lookupname = subtables[i]
+ local lookupcache = lookuphash[lookupname]
+ if lookupcache then
+ local lookupmatch = lookupcache[start.char]
+ if lookupmatch then
+ head, start, success = handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,i)
+ if success then
+ break
+ end
+ end
+ else
+ report_missing_cache(typ,lookupname)
end
end
- if start then start = start.next end
+ if start then start = start.prev end
else
- start = start.next
+ start = start.prev
end
else
- start = start.next
- end
- elseif id == disc_code then
- -- mostly for gsub
- if start.subtype == discretionary_code then
- local pre = start.pre
- if pre then
- local new = subrun(pre)
- if new then start.pre = new end
- end
- local post = start.post
- if post then
- local new = subrun(post)
- if new then start.post = new end
- end
- local replace = start.replace
- if replace then
- local new = subrun(replace)
- if new then start.replace = new end
- end
- end
- start = start.next
- elseif id == whatsit_code then -- will be function
- local subtype = start.subtype
- if subtype == dir_code then
- local dir = start.dir
- if dir == "+TRT" or dir == "+TLT" then
- topstack = topstack + 1
- dirstack[topstack] = dir
- elseif dir == "-TRT" or dir == "-TLT" then
- topstack = topstack - 1
- end
- local newdir = dirstack[topstack]
- if newdir == "+TRT" then
- rlmode = -1
- elseif newdir == "+TLT" then
- rlmode = 1
- else
- rlmode = rlparmode
- end
- if trace_directions then
- report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir)
- end
- elseif subtype == localpar_code then
- local dir = start.dir
- if dir == "TRT" then
- rlparmode = -1
- elseif dir == "TLT" then
- rlparmode = 1
- else
- rlparmode = 0
- end
- -- one might wonder if the par dir should be looked at, so we might as well drop the next line
- rlmode = rlparmode
- if trace_directions then
- report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode)
- end
+ start = start.prev
end
- start = start.next
- elseif id == math_code then
- start = end_of_math(start).next
else
- start = start.next
+ start = start.prev
end
end
- end
- else
-
- local function subrun(start)
- -- mostly for gsub, gpos would demand a more clever approach
- local head = start
- local done = false
- while start do
- local id = start.id
- if id == glyph_code and start.id == font and start.subtype <256 then
- local a = start[0]
- if a then
- a = (a == attr) and (not attribute or start[a_state] == attribute)
- else
- a = not attribute or start[a_state] == attribute
- end
- if a then
- for i=1,ns do
- local lookupname = subtables[i]
- local lookupcache = lookuphash[lookupname]
- if lookupcache then
- local lookupmatch = lookupcache[start.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[4],lookupname,lookupmatch,sequence,lookuphash,i)
- if ok then
- done = true
- break
- elseif not start then
- -- don't ask why ... shouldn't happen
- break
+ else
+ local handler = handlers[typ]
+ local ns = #subtables
+ local start = head -- local ?
+ rlmode = 0 -- to be checked ?
+ if ns == 1 then -- happens often
+ local lookupname = subtables[1]
+ local lookupcache = lookuphash[lookupname]
+ if not lookupcache then -- also check for empty cache
+ report_missing_cache(typ,lookupname)
+ else
+ while start do
+ local id = start.id
+ if id == glyph_code then
+ if start.font == font and start.subtype<256 then
+ local a = start[0]
+ if a then
+ a = (a == attr) and (not attribute or start[a_state] == attribute)
+ else
+ a = not attribute or start[a_state] == attribute
+ end
+ if a then
+ local lookupmatch = lookupcache[start.char]
+ if lookupmatch then
+ -- sequence kan weg
+ local ok
+ head, start, ok = handler(head,start,dataset[4],lookupname,lookupmatch,sequence,lookuphash,1)
+ if ok then
+ success = true
+ end
end
+ if start then start = start.next end
+ else
+ start = start.next
end
+ elseif id == math_code then
+ start = end_of_math(start).next
else
- report_missing_cache(typ,lookupname)
+ start = start.next
+ end
+ elseif id == whatsit_code then -- will be function
+ local subtype = start.subtype
+ if subtype == dir_code then
+ local dir = start.dir
+ if dir == "+TRT" or dir == "+TLT" then
+ topstack = topstack + 1
+ dirstack[topstack] = dir
+ elseif dir == "-TRT" or dir == "-TLT" then
+ topstack = topstack - 1
+ end
+ local newdir = dirstack[topstack]
+ if newdir == "+TRT" then
+ rlmode = -1
+ elseif newdir == "+TLT" then
+ rlmode = 1
+ else
+ rlmode = rlparmode
+ end
+ if trace_directions then
+ report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir)
+ end
+ elseif subtype == localpar_code then
+ local dir = start.dir
+ if dir == "TRT" then
+ rlparmode = -1
+ elseif dir == "TLT" then
+ rlparmode = 1
+ else
+ rlparmode = 0
+ end
+ rlmode = rlparmode
+ if trace_directions then
+ report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode)
+ end
end
+ start = start.next
+ elseif id == math_code then
+ start = end_of_math(start).next
+ else
+ start = start.next
end
- if start then start = start.next end
- else
- start = start.next
end
- else
- start = start.next
end
- end
- if done then
- success = true
- return head
- end
- end
-
- while start do
- local id = start.id
- if id == glyph_code then
- if start.font == font and start.subtype<256 then
- local a = start[0]
- if a then
- a = (a == attr) and (not attribute or start[a_state] == attribute)
- else
- a = not attribute or start[a_state] == attribute
- end
- if a then
- for i=1,ns do
- local lookupname = subtables[i]
- local lookupcache = lookuphash[lookupname]
- if lookupcache then
- local lookupmatch = lookupcache[start.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[4],lookupname,lookupmatch,sequence,lookuphash,i)
- if ok then
- success = true
- break
- elseif not start then
- -- don't ask why ... shouldn't happen
- break
+ else
+ while start do
+ local id = start.id
+ if id == glyph_code then
+ if start.font == font and start.subtype<256 then
+ local a = start[0]
+ if a then
+ a = (a == attr) and (not attribute or start[a_state] == attribute)
+ else
+ a = not attribute or start[a_state] == attribute
+ end
+ if a then
+ for i=1,ns do
+ local lookupname = subtables[i]
+ local lookupcache = lookuphash[lookupname]
+ if lookupcache then
+ local lookupmatch = lookupcache[start.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[4],lookupname,lookupmatch,sequence,lookuphash,i)
+ if ok then
+ success = true
+ break
+ elseif not start then
+ -- don't ask why ... shouldn't happen
+ break
+ end
+ end
+ else
+ report_missing_cache(typ,lookupname)
end
end
+ if start then start = start.next end
else
- report_missing_cache(typ,lookupname)
+ start = start.next
+ end
+ else
+ start = start.next
+ end
+ elseif id == whatsit_code then
+ local subtype = start.subtype
+ if subtype == dir_code then
+ local dir = start.dir
+ if dir == "+TRT" or dir == "+TLT" then
+ topstack = topstack + 1
+ dirstack[topstack] = dir
+ elseif dir == "-TRT" or dir == "-TLT" then
+ topstack = topstack - 1
+ end
+ local newdir = dirstack[topstack]
+ if newdir == "+TRT" then
+ rlmode = -1
+ elseif newdir == "+TLT" then
+ rlmode = 1
+ else
+ rlmode = rlparmode
+ end
+ if trace_directions then
+ report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir)
+ end
+ elseif subtype == localpar_code then
+ local dir = start.dir
+ if dir == "TRT" then
+ rlparmode = -1
+ elseif dir == "TLT" then
+ rlparmode = 1
+ else
+ rlparmode = 0
+ end
+ rlmode = rlparmode
+ if trace_directions then
+ report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode)
end
end
- if start then start = start.next end
- else
start = start.next
- end
- else
- start = start.next
- end
- elseif id == disc_code then
- -- mostly for gsub
- if start.subtype == discretionary_code then
- local pre = start.pre
- if pre then
- local new = subrun(pre)
- if new then start.pre = new end
- end
- local post = start.post
- if post then
- local new = subrun(post)
- if new then start.post = new end
- end
- local replace = start.replace
- if replace then
- local new = subrun(replace)
- if new then start.replace = new end
- end
- end
- start = start.next
- elseif id == whatsit_code then
- local subtype = start.subtype
- if subtype == dir_code then
- local dir = start.dir
- if dir == "+TRT" or dir == "+TLT" then
- topstack = topstack + 1
- dirstack[topstack] = dir
- elseif dir == "-TRT" or dir == "-TLT" then
- topstack = topstack - 1
- end
- local newdir = dirstack[topstack]
- if newdir == "+TRT" then
- rlmode = -1
- elseif newdir == "+TLT" then
- rlmode = 1
+ elseif id == math_code then
+ start = end_of_math(start).next
else
- rlmode = rlparmode
- end
- if trace_directions then
- report_process("directions after txtdir %a: parmode %a, txtmode %a, # stack %a, new dir %a",dir,rlparmode,rlmode,topstack,newdir)
- end
- elseif subtype == localpar_code then
- local dir = start.dir
- if dir == "TRT" then
- rlparmode = -1
- elseif dir == "TLT" then
- rlparmode = 1
- else
- rlparmode = 0
- end
- rlmode = rlparmode
- if trace_directions then
- report_process("directions after pardir %a: parmode %a, txtmode %a",dir,rlparmode,rlmode)
+ start = start.next
end
end
- start = start.next
- elseif id == math_code then
- start = end_of_math(start).next
- else
- start = start.next
end
end
- end
- end
- if success then
- done = true
- end
- if trace_steps then -- ?
- registerstep(head)
- end
+ if success then
+ done = true
+ end
+ if trace_steps then -- ?
+ registerstep(head)
+ end
+
+-- end
+-- else
+-- -- report_process("warning, no dataset %a",s)
+-- end
+
end
return head, done
end
diff --git a/tex/context/base/font-otx.lua b/tex/context/base/font-otx.lua
index f39045223..5c41ad66f 100644
--- a/tex/context/base/font-otx.lua
+++ b/tex/context/base/font-otx.lua
@@ -32,7 +32,6 @@ local a_state = attributes.private('state')
local nodecodes = nodes.nodecodes
local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
local math_code = nodecodes.math
local traverse_id = node.traverse_id
@@ -80,12 +79,6 @@ local features = {
fina = 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,
}
analyzers.states = states
@@ -130,7 +123,7 @@ function analyzers.setstate(head,font)
end
elseif id == disc_code then
-- always in the middle
- current[a_state] = s_medi
+ current[a_state] = s_midi
last = current
else -- finish
if first and first == last then
@@ -191,7 +184,7 @@ end
registerotffeature {
name = "analyze",
- description = "analysis of character classes",
+ description = "analysis of (for instance) character classes",
default = true,
initializers = {
node = analyzeinitializer,
diff --git a/tex/context/base/font-pat.lua b/tex/context/base/font-pat.lua
index 9733c9ada..3ad37641c 100644
--- a/tex/context/base/font-pat.lua
+++ b/tex/context/base/font-pat.lua
@@ -20,25 +20,25 @@ local patches = otf.enhancers.patches
local register = patches.register
local report = patches.report
--- local function patch(data,filename)
--- if not metadata.design_size or metadata.design_size == 0 then
--- local ds = match(file.basename(lower(filename)),"(%d+)")
--- if ds then
--- report("font %a has design size %a",filename,ds)
--- metadata.design_size = tonumber(ds) * 10
--- end
--- end
--- end
---
--- register("after","migrate metadata","^lmroman", patch)
--- register("after","migrate metadata","^lmsans", patch)
--- register("after","migrate metadata","^lmtypewriter",patch)
+local function patch(data,filename)
+ if data.design_size == 0 then
+ local ds = match(file.basename(lower(filename)),"(%d+)")
+ if ds then
+ report("font %a has design size %a",filename,ds)
+ data.design_size = tonumber(ds) * 10
+ end
+ end
+end
+
+register("after","migrate metadata","^lmroman", patch)
+register("after","migrate metadata","^lmsans", patch)
+register("after","migrate metadata","^lmtypewriter",patch)
-- For some reason (either it's a bug in the font, or it's a problem in the
-- library) the palatino arabic fonts don't have the mkmk features properly
-- set up.
-register("after","rehash features","^palatino.*arabic", function patch(data,filename)
+local function patch(data,filename)
local gpos = data.gpos
if gpos then
for k=1,#gpos do
@@ -61,7 +61,9 @@ register("after","rehash features","^palatino.*arabic", function patch(data,file
end
end
end
-end)
+end
+
+register("after","rehash features","palatino.*arabic",patch)
-- -- this code is now in lm-math.lfg
--
diff --git a/tex/context/base/font-pre.mkiv b/tex/context/base/font-pre.mkiv
index 75f42f8f5..b03abed7d 100644
--- a/tex/context/base/font-pre.mkiv
+++ b/tex/context/base/font-pre.mkiv
@@ -17,15 +17,11 @@
%D A basic set of features is defined here.
-% beware, base mode + dynamics can give weird effects
-
-% rlig ccmp
-
\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
- kern=yes, % consider skipping the base passes when no base mode is used
+ [mode=auto,
+ script=auto,
+ kern=yes,
mark=yes,
mkmk=yes,
curs=yes]
@@ -63,15 +59,6 @@
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]
@@ -85,38 +72,28 @@
[mode=none,
features=no]
-\definefontfeature
- [semetic-complete]
- [mode=node,analyze=yes,language=dflt,ccmp=yes,
- init=yes,medi=yes,fina=yes,isol=yes,
- mark=yes,mkmk=yes,kern=yes,curs=yes,
- liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes]
-
-\definefontfeature
- [semetic-simple]
- [mode=node,analyze=yes,language=dflt,ccmp=yes,
- init=yes,medi=yes,fina=yes,isol=yes,
- mark=yes,mkmk=yes,kern=yes,curs=yes,
- rlig=yes,calt=yes]
-
-\definefontfeature
+\definefontfeature % might move
[arabic]
- [semetic-complete]
- [script=arab]
+ [mode=node,language=dflt,script=arab,ccmp=yes,
+ init=yes,medi=yes,fina=yes,isol=yes,
+ liga=yes,dlig=yes,rlig=yes,clig=yes,calt=yes,
+ mark=yes,mkmk=yes,kern=yes,curs=yes]
\definefontfeature
[hebrew]
- [semetic-complete]
+ [arabic]
[script=hebr]
-\definefontfeature
+\definefontfeature % might move
[simplearabic]
- [semetic-simple]
- [script=arab]
+ [mode=node,language=dflt,script=arab,
+ init=yes,medi=yes,fina=yes,
+ rlig=yes,calt=yes,
+ mark=yes,mkmk=yes,curs=yes]
\definefontfeature
[simplehebrew]
- [semetic-simple]
+ [simplearabic]
[script=hebr]
% \definefont [DevaOne] [file:chandas.ttf*devanagari-one at 12pt]
@@ -174,7 +151,6 @@
trep=yes,
mathalternates=yes,
mathitalics=yes,
- % mathgaps=yes,
% nomathitalics=yes, % don't pass to tex, might become default
language=dflt,
script=math]
@@ -219,21 +195,6 @@
[missing]
[missing=yes]
-%D Nice to have too:
-
-\definefontfeature
- [quality]
- [expansion=quality,
- protrusion=quality]
-
-\definefontfeature
- [slanted]
- [slant=.2]
-
-\definefontfeature
- [boldened]
- [extend=1.2]
-
%D We define some colors that are used in tracing (for instance \OPENTYPE\
%D features). We cannot yet inherit because no colors are predefined.
@@ -536,7 +497,6 @@
\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 ]}]
@@ -563,7 +523,7 @@
%D
%D For tracing purposes we define:
-\definefont[tinyfont][dejavusansmono at 1ex]
+\definefont[tinyfont][Mono at 1ex]
%D \macros
%D {infofont}
@@ -575,7 +535,7 @@
\let\infofont\relax % satisfy dep checker
-\definefont[infofont][dejavusansmono at 6pt] % todo \the\everybodyfont
+\definefont [infofont] [Mono at 6pt] % todo \the\everybodyfont
\protect \endinput
diff --git a/tex/context/base/font-sel.lua b/tex/context/base/font-sel.lua
deleted file mode 100644
index 0c8985f4a..000000000
--- a/tex/context/base/font-sel.lua
+++ /dev/null
@@ -1,672 +0,0 @@
-if not modules then modules = { } end modules ['font-sel'] = {
- version = 1.000,
- comment = "companion to font-sel.mkvi",
- author = "Wolfgang Schuster",
- copyright = "Wolfgang Schuster",
- license = "GNU General Public License"
-}
-
-local context = context
-local cleanname = fonts.names.cleanname
-local gsub, splitup, find = string.gsub, string.splitup, string.find
-local formatters = string.formatters
-local settings_to_array = utilities.parsers.settings_to_array
-
-local v_yes = interfaces.variables.yes
-local v_simplefonts = interfaces.variables.simplefonts
-local v_selectfont = interfaces.variables.selectfont
-local v_default = interfaces.variables.default
-
-local selectfont = fonts.select or { }
-fonts.select = selectfont
-
-local data = selectfont.data or { }
-selectfont.data = data
-
-local fallbacks = selectfont.fallbacks or { }
-selectfont.fallbacks = fallbacks
-
-local methods = selectfont.methods or { }
-selectfont.methods = methods
-
-local getlookups = fonts.names.getlookups
-local registerdesignsizes = fonts.goodies.designsizes.register
-
-local alternatives = {
- ["tf"] = "regular",
- ["it"] = "italic",
- ["sl"] = "slanted",
- ["bf"] = "bold",
- ["bi"] = "bolditalic",
- ["bs"] = "boldslanted",
- ["sc"] = "smallcaps",
-}
-
-local styles = {
- ["rm"] = "serif",
- ["ss"] = "sans",
- ["tt"] = "mono",
- ["hw"] = "handwriting",
- ["cg"] = "calligraphy",
- ["mm"] = "math",
-}
-
-local sizes = {
- ["default"] = {
- { 40, "4pt" },
- { 50, "5pt" },
- { 60, "6pt" },
- { 70, "7pt" },
- { 80, "8pt" },
- { 90, "9pt" },
- { 100, "10pt" },
- { 110, "11pt" },
- { 120, "12pt" },
- { 144, "14.4pt" },
- { 173, "17.3pt" },
- },
- ["dtp"] = {
- { 50, "5pt" },
- { 60, "6pt" },
- { 70, "7pt" },
- { 80, "8pt" },
- { 90, "9pt" },
- { 100, "10pt" },
- { 110, "11pt" },
- { 120, "12pt" },
- { 130, "13pt" },
- { 140, "14pt" },
- { 160, "16pt" },
- { 180, "18pt" },
- { 220, "22pt" },
- { 280, "28pt" },
- }
-}
-
-local synonyms = {
- ["rm"] = {
- ["tf"] = "Serif",
- ["it"] = "SerifItalic",
- ["sl"] = "SerifSlanted",
- ["bf"] = "SerifBold",
- ["bi"] = "SerifBoldItalic",
- ["bs"] = "SerifBoldSlanted",
- ["sc"] = "SerifCaps",
- },
- ["ss"] = {
- ["tf"] = "Sans",
- ["it"] = "SansItalic",
- ["sl"] = "SansSlanted",
- ["bf"] = "SansBold",
- ["bi"] = "SansBoldItalic",
- ["bs"] = "SansBoldSlanted",
- ["sc"] = "SansCaps",
- },
- ["tt"] = {
- ["tf"] = "Mono",
- ["it"] = "MonoItalic",
- ["sl"] = "MonoSlanted",
- ["bf"] = "MonoBold",
- ["bi"] = "MonoBoldItalic",
- ["bs"] = "MonoBoldSlanted",
- ["sc"] = "MonoCaps",
- },
- ["hw"] = {
- ["tf"] = "Handwriting",
- },
- ["cg"] = {
- ["tf"] = "Calligraphy",
- },
- ["mm"] = {
- ["tf"] = "MathRoman",
- ["bf"] = "MathBold",
- }
-}
-
-local replacement = {
- ["style"] = {
- ["it"] = "tf",
- ["sl"] = "it",
- ["bf"] = "tf",
- ["bi"] = "bf",
- ["bs"] = "bi",
- ["sc"] = "tf",
- },
- ["weight"] = {
- ["it"] = "tf",
- ["sl"] = "tf",
- ["bf"] = "tf",
- ["bi"] = "bf",
- ["bs"] = "bf",
- ["sc"] = "tf",
- },
-}
-
-local names = {
- ["selectfont"] = { -- weight, style, width, variant, italic
- ["regular"] = { weight = "normal", style = "normal", width = "normal", variant = "normal", italic = false },
- ["italic"] = { weight = "normal", style = "italic", width = "normal", variant = "normal", italic = true },
- ["slanted"] = { weight = "normal", style = "slanted", width = "normal", variant = "normal", italic = true },
- ["medium"] = { weight = "medium", style = "normal", width = "normal", variant = "normal", italic = false },
- ["mediumitalic"] = { weight = "medium", style = "italic", width = "normal", variant = "normal", italic = true },
- ["mediumcaps"] = { weight = "medium", style = "normal", width = "normal", variant = "smallcaps", italic = true },
- ["bold"] = { weight = "bold", style = "normal", width = "normal", variant = "normal", italic = false },
- ["bolditalic"] = { weight = "bold", style = "italic", width = "normal", variant = "normal", italic = true },
- ["boldslanted"] = { weight = "bold", style = "slanted", width = "normal", variant = "normal", italic = true },
- ["smallcaps"] = { weight = "normal", style = "normal", width = "normal", variant = "smallcaps", italic = false },
- },
- ["simplefonts"] = {
- ["light"] = { "lightregular", "light" },
- ["lightitalic"] = { "lightitalic", "lightit", "lightoblique" },
- ["lightcaps"] = { "smallcapslight" },
- ["regular"] = { "roman", "regular", "book", "" },
- ["italic"] = { "italic", "it", "oblique", "kursiv", "bookitalic", "bookit" },
- ["medium"] = { "mediumregular", "medregular", "medium" },
- ["mediumitalic"] = { "mediumitalic", "meditalic" },
- ["mediumcaps"] = { "mediumcaps" },
- ["bold"] = { "bold", "bd", "kraeftig", "mediumregular", "semibold", "demi" },
- ["bolditalic"] = { "bolditalic", "boldit", "bdit", "boldoblique", "mediumitalic", "semibolditalic", "demiitalic" },
- ["smallcaps"] = { "smallcaps", "capitals", "sc" },
- ["heavy"] = { "heavyregular", "heavy" },
- ["heavyitalic"] = { "heavyitalic" },
- },
- ["default"] = { -- weight, width, italic
- ["thin"] = { weight = { 100, 200, 300, 400, 500 }, width = 5, italic = false },
- ["extralight"] = { weight = { 200, 100, 300, 400, 500 }, width = 5, italic = false },
- ["light"] = { weight = { 300, 200, 100, 400, 500 }, width = 5, italic = false },
- ["regular"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = false },
- ["italic"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = true },
- ["medium"] = { weight = { 500, 400, 300, 200, 100 }, width = 5, italic = false },
- ["demibold"] = { weight = { 600, 700, 800, 900 }, width = 5, italic = false },
- ["bold"] = { weight = { 700, 600, 800, 900 }, width = 5, italic = false },
- ["bolditalic"] = { weight = { 700, 600, 800, 900 }, width = 5, italic = true },
- ["smallcaps"] = { weight = { 400, 500, 300, 200, 100 }, width = 5, italic = false },
- ["heavy"] = { weight = { 800, 900, 700, 600 }, width = 5, italic = false },
- ["black"] = { weight = { 900, 800, 700, 600 }, width = 5, italic = false },
- }
-}
-
-names.simplefonts.slanted = names.simplefonts.italic
-names.simplefonts.boldslanted = names.simplefonts.bolditalic
-
-names.default.normal = names.default.regular
-names.default.slanted = names.default.italic
-names.default.semibold = names.default.demibold
-names.default.boldslanted = names.default.bolditalic
-
-local mathsettings = {
- ["asanamath"] = {
- extras = "asana-math",
- goodies = {
- ["tf"] = "anana-math",
- },
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["cambriamath"] = {
- extras = "cambria-math",
- goodies = {
- ["tf"] = "cambria-math",
- },
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["neoeuler"] = {
- extras = "euler-math",
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["latinmodernmath"] = {
- extras = "lm,lm-math",
- goodies = {
- ["tf"] = "lm",
- },
- features = {
- ["tf"] = "math\\mathsizesuffix,lm-math",
- },
- },
- ["lucidabrightmathot"] = {
- extras = "lucida-opentype-math",
- goodies = {
- ["tf"] = "lucida-opentype-math",
- },
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["texgyrepagellamath"] = {
- extras = "texgyre",
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["texgyrebonummath"] = {
- extras = "texgyre",
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["texgyretermesmath"] = {
- extras = "texgyre",
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
- ["xitsmath"] = {
- extras = "xits-math",
- goodies = {
- ["tf"] = "xits-math",
- },
- features = {
- ["tf"] = "math\\mathsizesuffix",
- },
- },
-}
-
-function commands.defineselectfont(settings)
- local index = #data + 1
- data[index] = settings
- selectfont.searchfiles(index)
- selectfont.filterinput(index)
- context(index)
-end
-
-local function savefont(data,alternative,entries)
- local f = data.fonts
- if not f then
- f = { }
- data.fonts = f
- end
- f[alternative] = entries
-end
-
-local function savefeatures(data,alternative,entries)
- local f = data.features
- if not f then
- f = { }
- data.features = f
- end
- f[alternative] = entries
-end
-
-local function savegoodies(data,alternative,entries)
- local g = data.goodies
- if not f then
- g = { }
- data.goodies = g
- end
- g[alternative] = entries
-end
-
-methods[v_simplefonts] = function(data,alternative,style)
- local family = data.metadata.family
- local names = names["simplefonts"][style] or names["simplefonts"]["regular"]
- for _, name in next, names do
- local filename = cleanname(formatters["%s%s"](family,name))
- local fullname = getlookups{ fullname = filename }
- local fontname = getlookups{ fontname = filename }
- local cleanfilename = getlookups{ cleanfilename = filename }
- if #fullname > 0 then
- savefont(data,alternative,fullname)
- break
- elseif #fontname > 0 then
- savefont(data,alternative,fontname)
- break
- elseif #cleanfilename > 0 then
- savefont(data,alternative,cleanfilename)
- break
- end
- end
-end
-
-methods[v_default] = function(data,alternative,style)
- local family = data.metadata.family
- local spec = names["default"][style] or names["default"]["regular"]
- local weights = spec["weight"]
- for _, weight in next, weights do
- local pattern = getlookups{
- familyname = cleanname(family),
- pfmweight = weight,
- pfmwidth = spec["width"],
- }
- if #pattern > 0 then
- local fontfiles = { }
- for _, fontfile in next, pattern do
- if (fontfile["angle"] and spec["italic"] == true) or (not fontfile["angle"] and spec["italic"] == false) then
- fontfiles[#fontfiles + 1] = fontfile
- end
- end
- savefont(data,alternative,fontfiles)
- break
- end
- end
-end
-
-methods[v_selectfont] = function(data,alternative,style)
- local family = data.metadata.family
- local spec = names["selectfont"][style] or names["selectfont"]["regular"]
- local pattern = getlookups{
- familyname = cleanname(family),
- weight = spec["weight"],
- style = spec["style"],
- width = spec["width"],
- variant = spec["variant"]
- }
- if #pattern > 0 then
- local fontfiles = { }
- for _, fontfile in next, pattern do
- if (fontfile["angle"] and spec["italic"] == true) or (not fontfile["angle"] and spec["italic"] == false) then
- fontfiles[#fontfiles + 1] = fontfile
- end
- end
- savefont(data,alternative,fontfiles)
- end
-end
-
-methods["name"] = function(data,alternative,filename)
- local data = data
- local family = data.metadata.family
- local filename = cleanname(gsub(filename,"*",family))
- local fullname = getlookups{ fullname = filename }
- local fontname = getlookups{ fontname = filename }
- if #fullname > 0 then
- savefont(data,alternative,fullname)
- elseif #fontname > 0 then
- savefont(data,alternative,fontname)
- end
-end
-
-methods["file"] = function(data,alternative,filename)
- local data = data
- local family = data.metadata.family
- local filename = gsub(file.removesuffix(filename),"*",family)
- local filename = getlookups{ cleanfilename = cleanname(filename) }
- if #filename > 0 then
- savefont(data,alternative,filename)
- end
-end
-
-methods["spec"] = function(data,alternative,filename)
- local family = data.metadata.family
- local weight, style, width, variant = splitup(filename,"-")
- local pattern = getlookups{
- familyname = cleanname(family),
- weight = weight or "normal",
- style = style or "normal",
- width = width or "normal",
- variant = variant or "normal",
- }
- if #pattern > 0 then
- savefont(data,alternative,pattern)
- end
-end
-
-methods["style"] = function(data,alternative,style)
- local method = data.options.alternative or nil
- (methods[method] or methods[v_default])(data,alternative,style)
-end
-
-methods["features"] = function(data,alternative,features)
- savefeatures(data,alternative,features)
-end
-
-methods["goodies"] = function(data,alternative,goodies)
- savegoodies(data,alternative,goodies)
-end
-
-function selectfont.searchfiles(index)
- local data = data[index]
- for alternative, _ in next, alternatives do
- local filename = data.files[alternative]
- local method = data.options.alternative
- local family = data.metadata.family
- local style = alternatives[alternative]
- if filename == "" then
- local pattern = getlookups{ familyname = cleanname(family) }
- if #pattern == 1 and alternative == "tf" then -- needs to be improved
- savefont(data,alternative,pattern)
- else
- (methods[method] or methods[v_default])(data,alternative,style)
- end
- else
- method, filename = splitup(filename,":")
- if not filename then
- filename = method
- method = "name"
- end
- (methods[method] or methods["name"])(data,alternative,filename)
- end
- end
-end
-
-function selectfont.filterinput(index)
- local data = data[index]
- for alternative, _ in next, alternatives do
- local list = settings_to_array(data.alternatives[alternative])
- for _, entry in next, list do
- method, entries = splitup(entry,":")
- if not entries then
- entries = method
- method = "name"
- end
- (methods[method] or methods["name"])(data,alternative,entries)
- end
- end
-end
-
-local function definefontsynonym(data,alternative,index,fallback)
- local fontdata = data.fonts and data.fonts[alternative]
- local style = data.metadata.style
- local typeface = data.metadata.typeface
- local mathsettings = mathsettings[cleanname(data.metadata.family)]
- local features = mathsettings and mathsettings["features"] and (mathsettings["features"][alternative] or mathsettings["features"]["tf"]) or data.features and data.features[alternative] or ""
- local goodies = mathsettings and mathsettings["goodies"] and (mathsettings["goodies"] [alternative] or mathsettings["goodies"] ["tf"]) or data.goodies and data.goodies [alternative] or ""
- local parent = replacement["style"][alternative] or ""
- local fontname, fontfile, fontparent
- if fallback then
- fontname = formatters["%s-%s-%s-fallback-%s"](typeface, style, alternative, index)
- fontfile = formatters["%s-%s-%s-%s"] (typeface, style, alternative, index)
- fontparent = formatters["%s-%s-%s-fallback-%s"](typeface, style, parent, index)
- else
- fontname = synonyms[style][alternative]
- fontfile = formatters["%s-%s-%s"](typeface, style, alternative)
- fontparent = formatters["%s-%s-%s"](typeface, style, parent)
- end
- if fontdata and #fontdata > 0 then
- for _, size in next, sizes["default"] do
- for _, entry in next, fontdata do
- if entry["minsize"] and entry["maxsize"] then
- if size[1] > entry["minsize"] and size[1] <= entry["maxsize"] then
- registerdesignsizes( fontfile, size[2], entry["filename"] )
- end
- end
- end
- end
- for _, entry in next, fontdata do
- local filename = entry["filename"]
- local designsize = entry["designsize"] or 100
- if designsize == 100 or designsize == 120 or designsize == 0 then
- registerdesignsizes( fontfile, "default", filename )
- break
- end
- end
- if fallback then
- context.definefontsynonym( { fontname }, { fontfile }, { features = features } )
- else
- context.definefontsynonym( { fontname }, { fontfile }, { features = features, fallbacks = fontfile, goodies = goodies } )
- end
- else
- if fallback then
- context.definefontsynonym( { fontname }, { fontparent }, { features = features } )
- else
- context.definefontsynonym( { fontname }, { fontparent }, { features = features, fallbacks = fontfile, goodies = goodies } )
- end
- end
-end
-
-local function definetypescript(index)
- local data = data[index]
- local entry = data.fonts
- local mathsettings = mathsettings[cleanname(data.metadata.family)]
- local goodies = mathsettings and mathsettings.extras or data.options.goodies
- local typeface = data.metadata.typeface
- local style = data.metadata.style
- if entry and entry["tf"] then
- context.startfontclass( { typeface } )
- if goodies ~= "" then
- goodies = utilities.parsers.settings_to_array(goodies)
- for _, goodie in next, goodies do
- context.loadfontgoodies( { goodie } )
- end
- end
- for alternative, _ in next, alternatives do
- if synonyms[style][alternative] then -- prevent unnecessary synonyms for handwriting, calligraphy and math
- definefontsynonym(data,alternative)
- end
- end
- context.stopfontclass()
- else
- -- regular style not available, loading aborted
- end
-end
-
-function selectfont.registerfallback(typeface,style,index)
- local t = fallbacks[typeface]
- if not t then
- fallbacks[typeface] = { [style] = { index } }
- else
- local s = t[style]
- if not s then
- fallbacks[typeface][style] = { index }
- else
- fallbacks[typeface][style][#s+1] = index
- end
- end
-end
-
-local function definetextfontfallback(data,alternative,index)
- local typeface = data.metadata.typeface
- local style = data.metadata.style
- local features = data.features[alternative]
- local range = data.options.range
- local rscale = data.options.scale ~= "" and data.options.scale or 1
- local check = data.options.check ~= "" and data.options.check or "yes"
- local force = data.options.force ~= "" and data.options.force or "yes"
- local synonym = formatters["%s-%s-%s-fallback-%s"](typeface, style, alternative, index)
- local fallback = formatters["%s-%s-%s"] (typeface, style, alternative)
- if index == 1 then
- context.resetfontfallback( { fallback } )
- end
- context.definefontfallback( { fallback }, { synonym }, { range }, { rscale = rscale, check = check, force = force } )
-end
-
-local function definetextfallback(entry,index)
- local data = data[index]
- local typeface = data.metadata.typeface
- context.startfontclass( { typeface } )
- for alternative, _ in next, alternatives do
- definefontsynonym (data,alternative,entry,true)
- definetextfontfallback(data,alternative,entry)
- end
- context.stopfontclass()
- -- inspect(data)
-end
-
-local function definemathfontfallback(data,alternative,index)
- local typeface = data.metadata.typeface
- local style = data.metadata.style
- local range = data.options.range
- local rscale = data.options.scale ~= "" and data.options.scale or 1
- local check = data.options.check ~= "" and data.options.check or "yes"
- local force = data.options.force ~= "" and data.options.force or "yes"
- local offset = data.options.offset
- local features = data.features[alternative]
- local fontdata = data.fonts and data.fonts[alternative]
- local fallback = formatters["%s-%s-%s"](typeface, style, alternative)
- if index == 1 then
- context.resetfontfallback( { fallback } )
- end
- for _, entry in next, fontdata do
- local filename = entry["filename"]
- local designsize = entry["designsize"] or 100
- if designsize == 100 or designsize == 120 or designsize == 0 then
- context.definefontfallback( { fallback }, { formatters["%s*%s"](filename,features) }, { range }, { rscale = rscale, check = check, force = force, offset = offset } )
- break
- end
- end
-end
-
-local function definemathfallback(entry,index)
- local data = data[index]
- local typeface = data.metadata.typeface
- local style = data.metadata.style
- context.startfontclass( { typeface } )
- for alternative, _ in next, alternatives do
- if synonyms[style][alternative] then
- definemathfontfallback(data,alternative,entry)
- end
- end
- context.stopfontclass()
-end
-
-local function definefallbackfont(index)
- local data = data[index]
- local f = fallbacks[data.metadata.typeface]
- if f then
- local s = f[data.metadata.style]
- if s then
- for entry, fallback in next, s do
- if data.metadata.style == "mm" then
- definemathfallback(entry,fallback)
- else
- definetextfallback(entry,fallback)
- end
- end
- end
- end
-end
-
-local function definetextfont(index)
- local data = data[index]
- local fontclass = data.metadata.typeface
- local shortstyle = data.metadata.style
- local style = styles[data.metadata.style]
- local designsize = data.options.opticals == v_yes and "auto" or "default"
- local scale = data.options.scale ~= "" and data.options.scale or 1
- context.definetypeface( { fontclass }, { shortstyle }, { style }, { "" }, { "default" }, { designsize = designsize, rscale = scale } )
-end
-
-local function definemathfont(index)
- local data = data[index]
- local fontclass = data.metadata.typeface
- local shortstyle = data.metadata.style
- local style = styles[data.metadata.style]
- local scale = data.options.scale ~= "" and data.options.scale or 1
- local typescript = cleanname(data.metadata.family)
- local entries = data.fonts
- if entries then
- context.definetypeface( { fontclass }, { shortstyle }, { style }, { "" }, { "default" }, { rscale = scale } )
- else
- context.definetypeface( { fontclass }, { shortstyle }, { style }, { typescript }, { "default" }, { rscale = scale } )
- end
-end
-
-function selectfont.definetypeface(index)
- local data = data[index]
- if data.metadata.style == "mm" then
- definefallbackfont(index)
- definetypescript (index)
- definemathfont (index)
- else
- definefallbackfont(index)
- definetypescript (index)
- definetextfont (index)
- end
- -- inspect(data)
-end
-
-commands.definefontfamily = selectfont.definetypeface
-commands.definefallbackfamily = selectfont.registerfallback
diff --git a/tex/context/base/font-sel.mkvi b/tex/context/base/font-sel.mkvi
deleted file mode 100644
index 718da1fa2..000000000
--- a/tex/context/base/font-sel.mkvi
+++ /dev/null
@@ -1,341 +0,0 @@
-%D \module
-%D [ file=font-sel,
-%D version=2013.10.14,
-%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}{1.000}
-
-\unprotect
-
-\installcorenamespace {selectfont}
-\installsimplecommandhandler \??selectfont {selectfont}
-
-\unexpanded\def\selectfont_setparameters[#settings]%
- {\begingroup
- \setupcurrentselectfont[#settings]%
- \edef\p_selectfont_preset{\selectfontparameter\c!preset}%
- \ifx\p_selectfont_preset\empty \else
- \processcommacommand[\p_selectfont_preset]\selectfont_preset_process
- \setupcurrentselectfont[#settings]%
- \fi
- \setexpandedselectfontparameter\c!style {\expandnamespaceparameter\??selectfontstyle \selectfontparameter\c!style \s!rm }%
- \setexpandedselectfontparameter\c!alternative{\expandnamespaceparameter\??selectfontalternative\selectfontparameter\c!alternative\v!default}%
- \xdef\selectfont_index{\ctxcommand{
- defineselectfont {
- metadata = {
- typeface = "\selectfontparameter\c!name",
- style = "\selectfontparameter\c!style",
- family = "\selectfontparameter\c!family",
- },
- options = {
- opticals = "\selectfontparameter\c!opticalsize",
- scale = "\selectfontparameter\c!scale",
- goodies = "\selectfontparameter\c!goodies",
- alternative = "\selectfontparameter\c!alternative",
- range = "\selectfontparameter\c!range", % fallback only
- offset = "\selectfontparameter\c!offset", % fallback only
- check = "\selectfontparameter\c!check", % fallback only
- force = "\selectfontparameter\c!force", % fallback only
- },
- alternatives = {
- ["tf"] = "\selectfontparameter\s!tf",
- ["bf"] = "\selectfontparameter\s!bf",
- ["it"] = "\selectfontparameter\s!it",
- ["sl"] = "\selectfontparameter\s!sl",
- ["bi"] = "\selectfontparameter\s!bi",
- ["bs"] = "\selectfontparameter\s!bs",
- ["sc"] = "\selectfontparameter\s!sc",
- },
- files = {
- ["tf"] = "\selectfontparameter\c!regularfont",
- ["bf"] = "\selectfontparameter\c!boldfont",
- ["it"] = "\selectfontparameter\c!italicfont",
- ["sl"] = "\selectfontparameter\c!slantedfont",
- ["bi"] = "\selectfontparameter\c!bolditalicfont",
- ["bs"] = "\selectfontparameter\c!boldslantedfont",
- ["sc"] = "\selectfontparameter\c!smallcapsfont",
- },
- features = {
- ["tf"] = "\selectfontparameter\c!regularfeatures",
- ["bf"] = "\selectfontparameter\c!boldfeatures",
- ["it"] = "\selectfontparameter\c!italicfeatures",
- ["sl"] = "\selectfontparameter\c!slantedfeatures",
- ["bi"] = "\selectfontparameter\c!bolditalicfeatures",
- ["bs"] = "\selectfontparameter\c!boldslantedfeatures",
- ["sc"] = "\selectfontparameter\c!smallcapsfeatures",
- }
- }}}%
- \endgroup}
-
-%D \macros
-%D {defineselectfontstyle}
-
-\installcorenamespace {selectfontstyle}
-
-\unexpanded\def\defineselectfontstyle
- {\dodoubleargument\selectfont_style_define}
-
-\def\selectfont_style_define[#styles][#shortstyle]%
- {\processcommalist[#styles]{\selectfont_style_define_indeed{#shortstyle}}}
-
-\def\selectfont_style_define_indeed#shortstyle#style%
- {\setvalue{\??selectfontstyle#style}{#shortstyle}}
-
-\defineselectfontstyle [\s!rm,\s!serif] [\s!rm]
-\defineselectfontstyle [\s!ss,\s!sans] [\s!ss]
-\defineselectfontstyle [\s!tt,\s!mono] [\s!tt]
-\defineselectfontstyle [\s!hw,\s!handwriting] [\s!hw]
-\defineselectfontstyle [\s!cg,\s!calligraphy] [\s!cg]
-\defineselectfontstyle [\s!mm,\s!math] [\s!mm]
-
-%D \macros
-%D {definefontfamilypreset}
-
-\installcorenamespace {selectfontpreset}
-
-\unexpanded\def\definefontfamilypreset
- {\dodoubleargument\selectfont_preset_define}
-
-\def\selectfont_preset_define[#name][#settings]%
- {\doifassignmentelse{#settings}
- {\setvalue{\??selectfontpreset#name}{\setupcurrentselectfont[#settings]}}
- {\setvalue{\??selectfontpreset#name}{\csname\??selectfontpreset#settings\endcsname}}}
-
-\def\selectfont_preset_process#name%
- {\ifcsname\??selectfontpreset#name\endcsname
- \csname\??selectfontpreset#name\endcsname
- \else
- % unknown preset
- \fi}
-
-\definefontfamilypreset [r:chinese] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,bopomofo,bopomofoextended}]
-\definefontfamilypreset [r:japanese] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,hiragana,katakana}]
-\definefontfamilypreset [r:korean] [\c!range={cjkcompatibilityforms,cjkcompatibilityideographs,cjkcompatibilityideographssupplement,cjkradicalssupplement,cjkstrokes,cjksymbolsandpunctuation,cjkunifiedideographs,cjkunifiedideographsextensiona,cjkunifiedideographsextensionb,halfwidthandfullwidthforms,verticalforms,hangulcompatibilityjamo,hanguljamo,hanguljamoextendeda,hanguljamoextendedb,hangulsyllables}]
-\definefontfamilypreset [r:cyrillic] [\c!range={cyrillic,cyrillicextendeda,cyrillicextendedb,cyrillicsupplement}]
-\definefontfamilypreset [r:greek] [\c!range={greekandcoptic,greekextended,ancientgreeknumbers}]
-
-%D \macros
-%D {defineselectfontalternative}
-%D
-%D The results between the old {\em simplefonts} and the new {\em selectfont}
-%D can be different because simplefonts the name entries in the database to find
-%D the styles for a font while selectfont the newer spec-method to the find the
-%D files for each style.
-%D
-%D The used method depends on the command one uses to load a font but it is
-%D also possible to switch between them with the {\em alternative} key, possible
-%D values are:
-%D
-%D \startitemize[packed]
-%D \startitem selectfont and \stopitem
-%D \startitem simplefonts. \stopitem
-%D \stopitemize
-
-\installcorenamespace {selectfontalternative}
-
-\unexpanded\def\defineselectfontalternative
- {\dodoubleargument\selectfont_alternative_define}
-
-\def\selectfont_alternative_define[#name][#alternative]%
- {\setvalue{\??selectfontalternative#name}{#alternative}}
-
-\defineselectfontalternative [\v!selectfont ] [\v!selectfont ]
-\defineselectfontalternative [\v!simplefonts] [\v!simplefonts]
-\defineselectfontalternative [\v!default ] [\v!default ]
-
-%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 mendatory 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] [scale=1.1]
-%D
-%D \definefontfamily [office] [serif] [Times New Roman]
-%D \definefontfamily [office] [sans] [Arial] [scale=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] [scale=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,force=yes]
-%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{opticalsize} 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][opticalsize=yes]
-%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
-
-% regularfont = … | * … | name:… | name:* … | file:… | file:* … | spec:…-…-… | style:medium
-
-\unexpanded\def\definefontfamily
- {\doquadrupleempty\selectfont_family_define}
-
-\def\selectfont_family_define[#typeface][#style][#family][#settings]%
- {\doifassignmentelse{#settings}
- {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]}
- {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}%
- \ctxcommand{definefontfamily(\selectfont_index)}}
-
-\unexpanded\def\definefallbackfamily
- {\doquadrupleempty\selectfont_fallback_define}
-
-\def\selectfont_fallback_define[#typeface][#style][#family][#settings]%
- {\doifassignmentelse{#settings}
- {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},#settings]}
- {\selectfont_setparameters[\c!name={#typeface},\c!style={#style},\c!family={#family},\c!preset={#settings}]}%
- \edef\p_selectfont_style{\expandnamespacevalue\??selectfontstyle{#style}\s!rm}%
- \ctxcommand{definefallbackfamily("#typeface","\p_selectfont_style",\selectfont_index)}}
-
-%D \macros
-%D {setupfontfamily,setupfallbackfamily}
-%D
-%D For simple documents which don’t need complex font settings one could use
-%D the \tex{setupfontfamily} command where the requested font is enabled immediately
-%D without the need to load it with \tex{setupbodyfont}. The downside of this method
-%D is that processing of the document takes longer with each additional font which
-%D is set with \tex{setupfontfamily}.
-%D
-%D \starttyping
-%D \setupfontfamily [serif] [DejaVu Serif]
-%D \setupfontfamily [sans] [DejaVu Sans]
-%D \setupfontfamily [mono] [DejaVu Sans Mono]
-%D \setupfontfamily [math] [XITS Math] [scale=1.1]
-%D
-%D \starttext
-%D
-%D \rm Serif 123 \ss Sans \tt Mono \m{1+2=3}
-%D
-%D \stoptext
-%D \stoptyping
-
-\newcount\c_selectfont_family
-\newtoks \t_selectfont_fallback
-\newtoks \t_selectfont_styles
-
-\unexpanded\def\setupfontfamily
- {\dotripleempty\selectfont_family_setup}
-
-\def\selectfont_family_setup
- {\ifsecondargument
- \expandafter\selectfont_family_setup_yes
- \else
- \expandafter\selectfont_family_setup_nop
- \fi}
-
-\def\selectfont_family_setup_yes[#style][#family][#settings]%
- {\normalexpanded{\t_selectfont_styles{\selectfont_set_font_family[#style][#family][#settings]\the\t_selectfont_styles}}%
- \selectfont_set_font_indeed}
-
-\def\selectfont_family_setup_nop[#settings][#dummya][#dummyb]%
- {\setupselectfont[#settings]}
-
-\unexpanded\def\selectfont_set_default
- {\selectfont_set_font_family[\v!serif][Latin Modern Roman][\c!opticalsize=\v!yes]%
- \selectfont_set_font_family[\v!sans] [Latin Modern Sans] [\c!opticalsize=\v!yes]%
- \selectfont_set_font_family[\v!mono] [Latin Modern Mono] [\c!opticalsize=\v!yes,\c!features=\s!none]}
-
-\unexpanded\def\setupfallbackfamily
- {\dotripleempty\selectfont_fallback_setup}
-
-\def\selectfont_fallback_setup[#style][#family][#settings]%
- {\normalexpanded{\t_selectfont_fallback{\the\t_selectfont_fallback\selectfont_set_font_fallback[#style][#family][#settings]}}}
-
-\def\selectfont_set_font_indeed
- {\global\advance\c_selectfont_family\plusone
- \edef\m_selectfont_typeface{\v!selectfont-\number\c_selectfont_family}%
- \the\t_selectfont_fallback
- \the\t_selectfont_styles
- \selectfont_set_default
- \setupbodyfont[\m_selectfont_typeface,\rootselectfontparameter\c!style]}
-
-\unexpanded\def\selectfont_set_font_family[#style]#dummy[#family]#dummy[#settings]%
- {\ifcsname\m_selectfont_typeface#style\endcsname \else
- \expandafter\let\csname\m_selectfont_typeface#style\endcsname\relax
- \selectfont_family_define[\m_selectfont_typeface][#style][#family][#settings]%
- \fi}
-
-\unexpanded\def\selectfont_set_font_fallback[#style]#dummy[#family]#dummy[#settings]%
- {\selectfont_fallback_define[\m_selectfont_typeface][#style][#family][#settings]}
-
-%D You can apply a different feature set to each style of a font but if nothing
-%D is set the global features are used.
-
-\setupselectfont
- [ \c!features=\s!default,
- \c!regularfeatures=\selectfontparameter\c!features,
- \c!boldfeatures=\selectfontparameter\c!features,
- \c!italicfeatures=\selectfontparameter\c!features,
- \c!slantedfeatures=\selectfontparameter\c!features,
- \c!bolditalicfeatures=\selectfontparameter\c!features,
- \c!boldslantedfeatures=\selectfontparameter\c!features,
- \c!smallcapsfeatures=\s!smallcaps,
- \c!style=\s!rm]
-
-\protect
\ No newline at end of file
diff --git a/tex/context/base/font-sol.lua b/tex/context/base/font-sol.lua
index 9ccfd0588..db2dd24c2 100644
--- a/tex/context/base/font-sol.lua
+++ b/tex/context/base/font-sol.lua
@@ -571,7 +571,7 @@ local function doit(word,list,best,width,badness,line,set,listdir)
local font = found.font
local setdynamics = setfontdynamics[font]
if setdynamics then
- local processes = setdynamics[featurenumber]
+ local processes = setdynamics(font,featurenumber)
for i=1,#processes do -- often more than 1
first = processes[i](first,font,featurenumber)
end
diff --git a/tex/context/base/font-sty.mkvi b/tex/context/base/font-sty.mkvi
index 03fa598c2..3caa94488 100644
--- a/tex/context/base/font-sty.mkvi
+++ b/tex/context/base/font-sty.mkvi
@@ -172,8 +172,6 @@
%D The new one:
-\setfalse\fontattributeisset
-
\unexpanded\def\dousestyleparameter#value%
{\edef\currentstyleparameter{#value}%
\ifx\currentstyleparameter\empty\else
@@ -344,9 +342,6 @@
\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}
@@ -409,4 +404,5 @@
\let\dostopattributes\endgroup
+
\protect \endinput
diff --git a/tex/context/base/font-sym.mkvi b/tex/context/base/font-sym.mkvi
index c8ca49f74..e1d5332c4 100644
--- a/tex/context/base/font-sym.mkvi
+++ b/tex/context/base/font-sym.mkvi
@@ -52,10 +52,6 @@
\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
diff --git a/tex/context/base/font-syn.lua b/tex/context/base/font-syn.lua
index 18da4f2e1..27176dade 100644
--- a/tex/context/base/font-syn.lua
+++ b/tex/context/base/font-syn.lua
@@ -12,14 +12,13 @@ local next, tonumber, type, tostring = next, tonumber, type, tostring
local sub, gsub, lower, match, find, lower, upper = string.sub, string.gsub, string.lower, string.match, string.find, string.lower, string.upper
local find, gmatch = string.find, string.gmatch
local concat, sort, format = table.concat, table.sort, string.format
-local serialize, sortedhash = table.serialize, table.sortedhash
+local serialize = table.serialize
local lpegmatch = lpeg.match
local unpack = unpack or table.unpack
-local formatters, topattern = string.formatters, string.topattern
+local formatters = string.formatters
local allocate = utilities.storage.allocate
local sparse = utilities.storage.sparse
-local setmetatableindex = table.setmetatableindex
local removesuffix = file.removesuffix
local splitbase = file.splitbase
@@ -35,13 +34,11 @@ local findfile = resolvers.findfile
local cleanpath = resolvers.cleanpath
local resolveresolved = resolvers.resolve
-local settings_to_hash = utilities.parsers.settings_to_hash_tolerant
-
local trace_names = false trackers.register("fonts.names", function(v) trace_names = v end)
local trace_warnings = false trackers.register("fonts.warnings", function(v) trace_warnings = v end)
local trace_specifications = false trackers.register("fonts.specifications", function(v) trace_specifications = v end)
-local report_names = logs.reporter("fonts","names")
+local report_names = logs.reporter("fonts","names")
--[[ldx--
This module implements a name to filename resolver. Names are resolved
@@ -56,12 +53,9 @@ fonts.names = names
local filters = names.filters or { }
names.filters = filters
-local treatments = names.treatments or { }
-names.treatments = treatments
-
names.data = names.data or allocate { }
-names.version = 1.123
+names.version = 1.110
names.basename = "names"
names.saved = false
names.loaded = false
@@ -96,8 +90,7 @@ local weights = Cs ( -- not extra
+ P("heavy")
+ P("ultra")
+ P("black")
---+ P("bol") / "bold" -- blocks
- + P("bol")
+ + P("bol") -- / "bold"
+ P("regular") / "normal"
)
@@ -112,8 +105,8 @@ local styles = Cs (
+ P("oblique") / "italic"
+ P("slanted")
+ P("roman") / "normal"
- + P("ital") / "italic" -- might be tricky
- + P("ita") / "italic" -- might be tricky
+ + P("ital") / "italic"
+ + P("ita") / "italic"
)
local normalized_styles = sparse {
@@ -185,28 +178,6 @@ names.knownvariants = {
"smallcaps",
}
-local remappedweights = {
- [""] = "normal",
- ["bol"] = "bold",
-}
-
-local remappedstyles = {
- [""] = "normal",
-}
-
-local remappedwidths = {
- [""] = "normal",
-}
-
-local remappedvariants = {
- [""] = "normal",
-}
-
-names.remappedweights = remappedweights setmetatableindex(remappedweights ,"self")
-names.remappedstyles = remappedstyles setmetatableindex(remappedstyles ,"self")
-names.remappedwidths = remappedwidths setmetatableindex(remappedwidths ,"self")
-names.remappedvariants = remappedvariants setmetatableindex(remappedvariants,"self")
-
local any = P(1)
local analyzed_table
@@ -274,7 +245,6 @@ function fontloader.fullinfo(...) -- check with taco what we get / could get
end
filters.otf = fontloader.fullinfo
-filters.ttf = fontloader.fullinfo
function filters.afm(name)
-- we could parse the afm file as well, and then report an error but
@@ -287,7 +257,7 @@ function filters.afm(name)
local f = io.open(name)
if f then
local hash = { }
- for line in f:lines() do -- slow
+ for line in f:lines() do
local key, value = match(line,"^(.+)%s+(.+)%s*$")
if key and #key > 0 then
hash[lower(key)] = value
@@ -450,17 +420,15 @@ local function check_name(data,result,filename,modification,suffix,subfont)
-- prepare
local names = check_names(result)
-- fetch
- local familyname = names and names.preffamilyname or result.familyname
- local fullname = names and names.fullname or result.fullname
- local fontname = result.fontname
- local subfamily = names and names.subfamily
- local modifiers = names and names.prefmodifiers
- local weight = names and names.weight or result.weight
- local italicangle = tonumber(result.italicangle)
- local subfont = subfont or nil
- local rawname = fullname or fontname or familyname
- local filebase = removesuffix(basename(filename))
- local cleanfilename = cleanname(filebase) -- for WS
+ local familyname = names and names.preffamilyname or result.familyname
+ local fullname = names and names.fullname or result.fullname
+ local fontname = result.fontname
+ local subfamily = names and names.subfamily
+ local modifiers = names and names.prefmodifiers
+ local weight = names and names.weight or result.weight
+ local italicangle = tonumber(result.italicangle)
+ local subfont = subfont or nil
+ local rawname = fullname or fontname or familyname
-- normalize
familyname = familyname and cleanname(familyname)
fullname = fullname and cleanname(fullname)
@@ -490,42 +458,27 @@ local function check_name(data,result,filename,modification,suffix,subfont)
if not familyname then
familyname = a_name
end
- fontname = fontname or fullname or familyname or filebase -- maybe cleanfilename
+ fontname = fontname or fullname or familyname or basename(filename)
fullname = fullname or fontname
familyname = familyname or fontname
- -- we do these sparse
- local units = result.units_per_em or 1000
- local minsize = result.design_range_bottom or 0
- local maxsize = result.design_range_top or 0
- local designsize = result.design_size or 0
- local angle = result.italicangle or 0
- local pfminfo = result.pfminfo
- local pfmwidth = pfminfo and pfminfo.width or 0
- local pfmweight = pfminfo and pfminfo.weight or 0
- --
specifications[#specifications + 1] = {
- filename = filename, -- unresolved
- cleanfilename = cleanfilename,
- format = lower(suffix),
- subfont = subfont,
- rawname = rawname,
- familyname = familyname,
- fullname = fullname,
- fontname = fontname,
- subfamily = subfamily,
- modifiers = modifiers,
- weight = weight,
- style = style,
- width = width,
- variant = variant,
- units = units ~= 1000 and unit or nil,
- pfmwidth = pfmwidth ~= 0 and pfmwidth or nil,
- pfmweight = pfmweight ~= 0 and pfmweight or nil,
- angle = angle ~= 0 and angle or nil,
- minsize = minsize ~= 0 and minsize or nil,
- maxsize = maxsize ~= 0 and maxsize or nil,
- designsize = designsize ~= 0 and designsize or nil,
- modification = modification ~= 0 and modification or nil,
+ filename = filename, -- unresolved
+ format = lower(suffix),
+ subfont = subfont,
+ rawname = rawname,
+ familyname = familyname,
+ fullname = fullname,
+ fontname = fontname,
+ subfamily = subfamily,
+ modifiers = modifiers,
+ weight = weight,
+ style = style,
+ width = width,
+ variant = variant,
+ minsize = result.design_range_bottom or 0,
+ maxsize = result.design_range_top or 0,
+ designsize = result.design_size or 0,
+ modification = modification or 0,
}
end
@@ -549,10 +502,10 @@ local function cleanupkeywords()
local style = b_style or c_style or d_style or e_style or f_style or "normal"
local width = b_width or c_width or d_width or e_width or f_width or "normal"
local variant = b_variant or c_variant or d_variant or e_variant or f_variant or "normal"
- weight = remappedweights [weight or ""]
- style = remappedstyles [style or ""]
- width = remappedwidths [width or ""]
- variant = remappedvariants[variant or ""]
+ if not weight or weight == "" then weight = "normal" end
+ if not style or style == "" then style = "normal" end
+ if not width or width == "" then width = "normal" end
+ if not variant or variant == "" then variant = "normal" end
weights [weight ] = (weights [weight ] or 0) + 1
styles [style ] = (styles [style ] or 0) + 1
widths [width ] = (widths [width ] or 0) + 1
@@ -571,22 +524,12 @@ local function collectstatistics()
local data = names.data
local specifications = data.specifications
if specifications then
- local f_w = formatters["%i"]
- local f_a = formatters["%0.2f"]
- -- normal stuff
- local weights = { }
- local styles = { }
- local widths = { }
- local variants = { }
- -- weird stuff
- local angles = { }
- -- extra stuff
- local pfmweights = { } setmetatableindex(pfmweights,"table")
- local pfmwidths = { } setmetatableindex(pfmwidths, "table")
- -- main loop
+ local weights = { }
+ local styles = { }
+ local widths = { }
+ local variants = { }
for i=1,#specifications do
- local s = specifications[i]
- -- normal stuff
+ local s = specifications[i]
local weight = s.weight
local style = s.style
local width = s.width
@@ -595,64 +538,13 @@ local function collectstatistics()
if style then styles [style ] = (styles [style ] or 0) + 1 end
if width then widths [width ] = (widths [width ] or 0) + 1 end
if variant then variants[variant] = (variants[variant] or 0) + 1 end
- -- weird stuff
- local angle = f_a(tonumber(s.angle) or 0)
- angles[angle] = (angles[angles] or 0) + 1
- -- extra stuff
- local pfmweight = f_w(s.pfmweight or 0)
- local pfmwidth = f_w(s.pfmwidth or 0)
- local tweights = pfmweights[pfmweight]
- local twidths = pfmwidths [pfmwidth]
- tweights[pfmweight] = (tweights[pfmweight] or 0) + 1
- twidths[pfmwidth] = (twidths [pfmwidth] or 0) + 1
- end
- --
- local stats = data.statistics
- stats.weights = weights
- stats.styles = styles
- stats.widths = widths
- stats.variants = variants
- stats.angles = angles
- stats.pfmweights = pfmweights
- stats.pfmwidths = pfmwidths
- stats.fonts = #specifications
- --
- setmetatableindex(pfmweights,nil)
- setmetatableindex(pfmwidths, nil)
- --
- report_names("")
- report_names("weights")
- report_names("")
- report_names(formatters[" %T"](weights))
- report_names("")
- report_names("styles")
- report_names("")
- report_names(formatters[" %T"](styles))
- report_names("")
- report_names("widths")
- report_names("")
- report_names(formatters[" %T"](widths))
- report_names("")
- report_names("variants")
- report_names("")
- report_names(formatters[" %T"](variants))
- report_names("")
- report_names("angles")
- report_names("")
- report_names(formatters[" %T"](angles))
- report_names("")
- report_names("pfmweights")
- report_names("")
- for k, v in sortedhash(pfmweights) do
- report_names(formatters[" %-10s: %T"](k,v))
- end
- report_names("")
- report_names("pfmwidths")
- report_names("")
- for k, v in sortedhash(pfmwidths) do
- report_names(formatters[" %-10s: %T"](k,v))
end
- report_names("")
+ local stats = data.statistics
+ stats.weights = weights
+ stats.styles = styles
+ stats.widths = widths
+ stats.variants = variants
+ stats.fonts = #specifications
end
end
@@ -716,11 +608,8 @@ local function checkduplicate(where) -- fails on "Romantik" but that's a border
local specifications = data.specifications
local loaded = { }
if specifications and mapping then
- -- was: for _, m in sortedhash(mapping) do
- local order = filters.list
- for i=1,#order do
- local m = mapping[order[i]]
- for k, v in sortedhash(m) do
+ for _, m in next, mapping do
+ for k, v in next, m do
local s = specifications[v]
local hash = formatters["%s-%s-%s-%s-%s"](s.familyname,s.weight or "*",s.style or "*",s.width or "*",s.variant or "*")
local h = loaded[hash]
@@ -744,7 +633,7 @@ local function checkduplicate(where) -- fails on "Romantik" but that's a border
end
end
local n = 0
- for k, v in sortedhash(loaded) do
+ for k, v in table.sortedhash(loaded) do
local nv = #v
if nv > 1 then
if trace_warnings then
@@ -831,7 +720,7 @@ local function analyzefiles(olddata)
local oldindices = olddata and olddata.indices or { }
local oldspecifications = olddata and olddata.specifications or { }
local oldrejected = olddata and olddata.rejected or { }
- local treatmentdata = treatments.data or { } -- when used outside context
+ local treatmentdata = fonts.treatments.data
local function identify(completename,name,suffix,storedname)
local pathpart, basepart = splitbase(completename)
nofread = nofread + 1
@@ -1065,13 +954,12 @@ function names.identify(force)
analyzefiles(not force and names.readdata(names.basename))
rejectclashes()
collectfamilies()
- -- collectstatistics()
+ collectstatistics()
cleanupkeywords()
collecthashes()
checkduplicates()
addfilenames()
-- sorthashes() -- will be resorted when saved
- collectstatistics()
report_names("total scan time %0.3f seconds",os.gettimeofday()-starttime)
end
@@ -1683,131 +1571,46 @@ end
local lastlookups, lastpattern = { }, ""
--- function names.lookup(pattern,name,reload) -- todo: find
--- if lastpattern ~= pattern then
--- names.load(reload)
--- local specifications = names.data.specifications
--- local families = names.data.families
--- local lookups = specifications
--- if name then
--- lookups = families[name]
--- elseif not find(pattern,"=") then
--- lookups = families[pattern]
--- end
--- if trace_names then
--- report_names("starting with %s lookups for %a",#lookups,pattern)
--- end
--- if lookups then
--- for key, value in gmatch(pattern,"([^=,]+)=([^=,]+)") do
--- local t, n = { }, 0
--- if find(value,"*") then
--- value = topattern(value)
--- for i=1,#lookups do
--- local s = lookups[i]
--- if find(s[key],value) then
--- n = n + 1
--- t[n] = lookups[i]
--- end
--- end
--- else
--- for i=1,#lookups do
--- local s = lookups[i]
--- if s[key] == value then
--- n = n + 1
--- t[n] = lookups[i]
--- end
--- end
--- end
--- if trace_names then
--- report_names("%s matches for key %a with value %a",#t,key,value)
--- end
--- lookups = t
--- end
--- end
--- lastpattern = pattern
--- lastlookups = lookups or { }
--- end
--- return #lastlookups
--- end
-
-local function look_them_up(lookups,specification)
- for key, value in next, specification do
- local t, n = { }, 0
- if find(value,"*") then
- value = topattern(value)
- for i=1,#lookups do
- local s = lookups[i]
- if find(s[key],value) then
- n = n + 1
- t[n] = lookups[i]
- end
- end
- else
- for i=1,#lookups do
- local s = lookups[i]
- if s[key] == value then
- n = n + 1
- t[n] = lookups[i]
- end
- end
- end
- if trace_names then
- report_names("%s matches for key %a with value %a",#t,key,value)
- end
- lookups = t
- end
- return lookups
-end
-
-local function first_look(name,reload)
- names.load(reload)
- local data = names.data
- local specifications = data.specifications
- local families = data.families
- if name then
- return families[name]
- else
- return specifications
- end
-end
-
function names.lookup(pattern,name,reload) -- todo: find
- names.load(reload)
- local data = names.data
- local specifications = data.specifications
- local families = data.families
- local lookups = specifications
- if name then
- name = cleanname(name)
- end
- if type(pattern) == "table" then
- local familyname = pattern.familyname
- if familyname then
- familyname = cleanname(familyname)
- pattern.familyname = familyname
+ if lastpattern ~= pattern then
+ names.load(reload)
+ local specifications = names.data.specifications
+ local families = names.data.families
+ local lookups = specifications
+ if name then
+ lookups = families[name]
+ elseif not find(pattern,"=") then
+ lookups = families[pattern]
end
- local lookups = first_look(name or familyname,reload)
- if lookups then
- if trace_names then
- report_names("starting with %s lookups for '%T'",#lookups,pattern)
- end
- lookups = look_them_up(lookups,pattern)
+ if trace_names then
+ report_names("starting with %s lookups for %a",#lookups,pattern)
end
- lastpattern = false
- lastlookups = lookups or { }
- elseif lastpattern ~= pattern then
- local lookups = first_look(name or (not find(pattern,"=") and pattern),reload)
if lookups then
- if trace_names then
- report_names("starting with %s lookups for %a",#lookups,pattern)
- end
- local specification = settings_to_hash(pattern)
- local familyname = specification.familyname
- if familyname then
- familyname = cleanname(familyname)
- specification.familyname = familyname
+ for key, value in gmatch(pattern,"([^=,]+)=([^=,]+)") do
+ local t, n = { }, 0
+ if find(value,"*") then
+ value = string.topattern(value)
+ for i=1,#lookups do
+ local s = lookups[i]
+ if find(s[key],value) then
+ n = n + 1
+ t[n] = lookups[i]
+ end
+ end
+ else
+ for i=1,#lookups do
+ local s = lookups[i]
+ if s[key] == value then
+ n = n + 1
+ t[n] = lookups[i]
+ end
+ end
+ end
+ if trace_names then
+ report_names("%s matches for key %a with value %a",#t,key,value)
+ end
+ lookups = t
end
- lookups = look_them_up(lookups,specification)
end
lastpattern = pattern
lastlookups = lookups or { }
@@ -1919,49 +1722,3 @@ function names.resolvespec(askedname,sub) -- overloads previous definition
report_names("unresolved: %s",askedname)
end
end
-
--- We could generate typescripts with designsize info from the name database but
--- it's not worth the trouble as font names remain a mess: for instance how do we
--- idenfity a font? Names, families, subfamilies or whatever snippet can contain
--- a number related to the design size and so we end up with fuzzy logic again. So,
--- instead it's easier to make a few goody files.
---
--- local hash = { }
---
--- for i=1,#specifications do
--- local s = specifications[i]
--- local min = s.minsize or 0
--- local max = s.maxsize or 0
--- if min ~= 0 or max ~= 0 then
--- -- the usual name mess:
--- -- antykwa has modifiers so we need to take these into account, otherwise we get weird combinations
--- -- ebgaramond has modifiers with the size encoded, so we need to strip this in order to recognized similar styles
--- -- lm has 'slanted appended in some names so how to choose that one
--- --
--- local modifier = string.gsub(s.modifiers or "normal","%d","")
--- -- print funny modifier
--- local instance = string.formatters["%s-%s-%s-%s-%s-%s"](s.familyname,s.width,s.style,s.weight,s.variant,modifier)
--- local h = hash[instance]
--- if not h then
--- h = { }
--- hash[instance] = h
--- end
--- size = string.formatters["%0.1fpt"]((min)/10)
--- h[size] = s.filename
--- end
--- end
---
--- local newhash = { }
---
--- for k, v in next, hash do
--- if next(v,next(v)) then
--- -- local instance = string.match(k,"(.+)%-.+%-.+%-.+$")
--- local instance = string.match(k,"(.+)%-.+%-.+$")
--- local instance = string.gsub(instance,"%-normal$","")
--- if not newhash[instance] then
--- newhash[instance] = v
--- end
--- end
--- end
---
--- inspect(newhash)
diff --git a/tex/context/base/font-tfm.lua b/tex/context/base/font-tfm.lua
index 827d70586..316b947a3 100644
--- a/tex/context/base/font-tfm.lua
+++ b/tex/context/base/font-tfm.lua
@@ -110,7 +110,7 @@ local function read_from_tfm(specification)
constructors.applymanipulators("tfm",tfmdata,allfeatures.normal,trace_features,report_tfm)
if not features.encoding then
local encoding, filename = match(properties.filename,"^(.-)%-(.*)$") -- context: encoding-name.*
- if filename and encoding and encodings.known and encodings.known[encoding] then
+ if filename and encoding and encodings.known[encoding] then
features.encoding = encoding
end
end
diff --git a/tex/context/base/font-tra.mkiv b/tex/context/base/font-tra.mkiv
index 45d8a7280..1877c4904 100644
--- a/tex/context/base/font-tra.mkiv
+++ b/tex/context/base/font-tra.mkiv
@@ -186,7 +186,6 @@
\forgetparindent
\forgeteverypar
\tt
- \lefttoright
\hbox to \hsize \bgroup
\hbox to 6\emwidth{\bf font\hss}%
\vtop \bgroup
diff --git a/tex/context/base/font-trt.lua b/tex/context/base/font-trt.lua
index abc92ba52..6fc8028d1 100644
--- a/tex/context/base/font-trt.lua
+++ b/tex/context/base/font-trt.lua
@@ -6,11 +6,7 @@ if not modules then modules = { } end modules ['font-trt'] = {
license = "see context related readme files"
}
-local rawget, dofile, next, type = rawget, dofile, next, type
-
-local cleanfilename = fonts.names.cleanfilename
-local splitbase = file.splitbase
-local lower = string.lower
+local rawget, dofile, next = rawget, dofile, next
--[[ldx--
We provide a simple treatment mechanism (mostly because I want to demonstrate
@@ -18,24 +14,11 @@ something in a manual). It's one of the few places where an lfg file gets loaded
outside the goodies manager.
--ldx]]--
-local treatments = fonts.treatments or { }
-fonts.treatments = treatments
-
-local treatmentdata = treatments.data or utilities.storage.allocate()
-treatments.data = treatmentdata
-
-treatments.filename = "treatments.lfg"
-
-local trace_treatments = false trackers.register("fonts.treatments", function(v) trace_treatments = v end)
-local report_treatment = logs.reporter("fonts","treatment")
-
-treatments.report = report_treatment
-
-function treatments.trace(...)
- if trace_treatments then
- report_treatment(...)
- end
-end
+local treatments = utilities.storage.allocate()
+fonts.treatments = treatments
+local treatmentdata = { }
+treatments.data = treatmentdata
+treatments.filename = "treatments.lfg"
-- function treatments.load(name)
-- local filename = resolvers.findfile(name)
@@ -72,45 +55,3 @@ table.setmetatableindex(treatmentdata,function(t,k)
table.setmetatableindex(treatmentdata,nil)
return treatmentdata[k]
end)
-
-local function applyfix(fix,filename,data,n)
- if type(fix) == "function" then
- -- we assume that when needed the fix reports something
- -- if trace_treatments then
- -- report_treatment("applying treatment %a to file %a",n,filename)
- -- end
- fix(data)
- elseif trace_treatments then
- report_treatment("invalid treatment %a for file %a",n,filename)
- end
-end
-
-function treatments.applyfixes(filename,data)
- local filename = cleanfilename(filename)
- local pathpart, basepart = splitbase(filename)
- local treatment = treatmentdata[filename] or treatmentdata[basepart]
- if treatment then
- local fixes = treatment.fixes
- if not fixes then
- -- nothing to fix
- elseif type(fixes) == "table" then
- for i=1,#fixes do
- applyfix(fixes[i],filename,data,i)
- end
- else
- applyfix(fixes,filename,data,1)
- end
- end
-end
-
-function treatments.ignoredfile(fullname)
- local treatmentdata = treatments.data or { } -- when used outside context
- local _, basepart = splitbase(fullname)
- local treatment = treatmentdata[basepart] or treatmentdata[lower(basepart)]
- if treatment and treatment.ignored then
- report_treatment("font file %a resolved as %a is ignored, reason %a",basepart,fullname,treatment.comment or "unknown")
- return true
- end
-end
-
-fonts.names.ignoredfile = treatments.ignoredfile
diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv
index 9b9333fa9..80b8e35d9 100644
--- a/tex/context/base/grph-fig.mkiv
+++ b/tex/context/base/grph-fig.mkiv
@@ -25,21 +25,12 @@
% \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext
% \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext
-% we could use \typesetbuffer[*] to access the last one
+\newcount\c_grph_buffers_n
-\newconstant\c_grph_buffers_mode
-
-\let\lasttypesetbuffer\empty
+\let\m_grph_buffers_filename\empty
\unexpanded\def\typesetbuffer
- {\bgroup
- \setconstant\c_grph_buffers_mode\plusone
- \dodoubleempty\grph_buffers_typeset}
-
-\unexpanded\def\typesetbufferonly
- {\bgroup
- \setconstant\c_grph_buffers_mode\zerocount
- \dodoubleempty\grph_buffers_typeset}
+ {\dodoubleempty\grph_buffers_typeset}
\def\grph_buffers_typeset[#1][#2]% beware: this will mix up the mp graphics
{\ifsecondargument
@@ -53,12 +44,11 @@
\fi\fi}
\def\grph_buffers_typeset_indeed[#1][#2]% we could use the via files
- {\doifnot{#1}{*}{\xdef\lasttypesetbuffer{\ctxcommand{runbuffer("#1",true)}}}%
- \ifcase\c_grph_buffers_mode
- % typesetonly
- \or
- \externalfigure[\lasttypesetbuffer][#2]%
- \fi
+ {\bgroup
+ \global\advance\c_grph_buffers_n\plusone
+ \edef\m_grph_buffers_filename{\jobname-buffer-\the\c_grph_buffers_n}%
+ \ctxcommand{runbuffer("\m_grph_buffers_filename.tmp","#1",true)}%
+ \externalfigure[\m_grph_buffers_filename.pdf][#2]%
\egroup}
% For manuals and such:
diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua
index 392aa58b1..9603419ae 100644
--- a/tex/context/base/grph-inc.lua
+++ b/tex/context/base/grph-inc.lua
@@ -38,6 +38,7 @@ run TeX code from within Lua. Some more functionality will move to Lua.
]]--
local format, lower, find, match, gsub, gmatch = string.format, string.lower, string.find, string.match, string.gsub, string.gmatch
+local texbox = tex.box
local contains = table.contains
local concat, insert, remove = table.concat, table.insert, table.remove
local todimen = string.todimen
@@ -54,15 +55,6 @@ local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
local replacetemplate = utilities.templates.replace
-local images = img
-
-local texgetbox = tex.getbox
-local texsetbox = tex.setbox
-
-local hpack = node.hpack
-
-local context = context
-
local variables = interfaces.variables
local codeinjections = backends.codeinjections
local nodeinjections = backends.nodeinjections
@@ -75,6 +67,8 @@ local trace_inclusion = false trackers.register("graphics.inclusion", functi
local report_inclusion = logs.reporter("graphics","inclusion")
+local context, img = context, img
+
local f_hash_part = formatters["%s->%s->%s"]
local f_hash_full = formatters["%s->%s->%s->%s->%s->%s->%s"]
@@ -88,7 +82,7 @@ local v_default = variables.default
local maxdimen = 2^30-1
-function images.check(figure)
+function img.check(figure)
if figure then
local width = figure.width
local height = figure.height
@@ -109,38 +103,36 @@ end
--- some extra img functions --- can become luat-img.lua
-local allimagekeys = images.keys()
+local imgkeys = img.keys()
-local function imagetotable(imgtable)
+function img.totable(imgtable)
local result = { }
- for k=1,#allimagekeys do
- local key = allimagekeys[k]
+ for k=1,#imgkeys do
+ local key = imgkeys[k]
result[key] = imgtable[key]
end
return result
end
-images.totable = imagetotable
-
-function images.serialize(i,...)
- return table.serialize(imagetotable(i),...)
+function img.serialize(i,...)
+ return table.serialize(img.totable(i),...)
end
-function images.print(i,...)
- return table.print(imagetotable(i),...)
+function img.print(i,...)
+ return table.print(img.totable(i),...)
end
-function images.clone(i,data)
+function img.clone(i,data)
i.width = data.width or i.width
i.height = data.height or i.height
-- attr etc
return i
end
-local validsizes = table.tohash(images.boxes())
-local validtypes = table.tohash(images.types())
+local validsizes = table.tohash(img.boxes())
+local validtypes = table.tohash(img.types())
-function images.checksize(size)
+function img.checksize(size)
if size then
size = gsub(size,"box","")
return validsizes[size] and size or "crop"
@@ -151,7 +143,7 @@ end
local indexed = { }
-function images.ofindex(n)
+function img.ofindex(n)
return indexed[n]
end
@@ -438,7 +430,7 @@ function figures.initialize(request)
request.height = h > 0 and h or nil
--
request.page = math.max(tonumber(request.page) or 1,1)
- request.size = images.checksize(request.size)
+ request.size = img.checksize(request.size)
request.object = request.object == v_yes
request["repeat"] = request["repeat"] == v_yes
request.preview = request.preview == v_yes
@@ -742,9 +734,6 @@ local function locate(request) -- name, format, cache
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
@@ -764,7 +753,6 @@ local function locate(request) -- name, format, cache
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
@@ -983,7 +971,7 @@ 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)
+ local box = texbox[nr]
ds.width = box.width
ds.height = box.height
ds.xscale = ds.width /(du.width or 1)
@@ -995,7 +983,7 @@ 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)
+ local box = node.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
@@ -1003,7 +991,7 @@ function figures.dummy(data)
box.width = du.width
box.height = du.height
box.depth = du.depth
- texsetbox(nr,box) -- hm, should be global (to be checked for consistency)
+ texbox[nr] = box -- hm, should be global (to be checked for consistency)
end
-- -- -- generic -- -- --
@@ -1045,7 +1033,7 @@ function checkers.generic(data)
local hash = f_hash_full(name,page,size,color,conversion,resolution,mask)
local figure = figures_loaded[hash]
if figure == nil then
- figure = images.new {
+ figure = img.new {
filename = name,
page = page,
pagebox = dr.size,
@@ -1053,7 +1041,7 @@ function checkers.generic(data)
}
codeinjections.setfigurecolorspace(data,figure)
codeinjections.setfiguremask(data,figure)
- figure = figure and images.check(images.scan(figure)) or false
+ figure = figure and img.check(img.scan(figure)) or false
local f, d = codeinjections.setfigurealternative(data,figure)
figure, data = f or figure, d or data
figures_loaded[hash] = figure
@@ -1096,18 +1084,18 @@ function includers.generic(data)
if figure == nil then
figure = ds.private
if figure then
- figure = images.copy(figure)
- figure = figure and images.clone(figure,data.request) or false
+ figure = img.copy(figure)
+ figure = figure and img.clone(figure,data.request) or false
end
figures_used[hash] = figure
end
if figure then
local nr = figures.boxnumber
-- it looks like we have a leak in attributes here .. todo
- local box = hpack(images.node(figure)) -- images.node(figure) not longer valid
+ local box = node.hpack(img.node(figure)) -- img.node(figure) not longer valid
indexed[figure.index] = figure
box.width, box.height, box.depth = figure.width, figure.height, 0 -- new, hm, tricky, we need to do that in tex (yet)
- texsetbox(nr,box)
+ texbox[nr] = box
ds.objectnumber = figure.objnum
context.relocateexternalfigure()
end
diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv
index 5fb87a8b2..8557bbb0b 100644
--- a/tex/context/base/grph-inc.mkiv
+++ b/tex/context/base/grph-inc.mkiv
@@ -297,12 +297,11 @@
%
\edef\p_width {\externalfigureparameter\c!width}%
\edef\p_height{\externalfigureparameter\c!height}%
- \edef\p_label {\externalfigureparameter\c!label}%
%
\dostarttagged\t!image\empty
\ctxlua{figures.push {
name = "\p_grph_include_name",
- label = "\ifx\p_label\empty\p_grph_include_label\else\p_label\fi",
+ label = "\p_grph_include_label",
page = "\externalfigureparameter\c!page",
size = "\externalfigureparameter\c!size",
object = "\externalfigureparameter\c!object",
@@ -611,9 +610,7 @@
\letexternalfigureparameter\c!offset\v!overlay
\letexternalfigureparameter\c!width \figurewidth
\letexternalfigureparameter\c!height\figureheight
-% \letexternalfigureparameter\c!align \v!middle
-% \letexternalfigureparameter\c!autowidth\v!no
- \inheritedexternalfigureframed{\box\foundexternalfigure}%
+ \inheritedexternalfigureframed{\vfilll\box\foundexternalfigure}%
\fi
\fi\fi
\fi
diff --git a/tex/context/base/java-ini.lua b/tex/context/base/java-ini.lua
index 673379494..321e4e24d 100644
--- a/tex/context/base/java-ini.lua
+++ b/tex/context/base/java-ini.lua
@@ -6,36 +6,30 @@ if not modules then modules = { } end modules ['java-ini'] = {
license = "see context related readme files"
}
--- todo: don't flush scripts if no JS key
-
local format = string.format
local concat = table.concat
local lpegmatch, P, S, C, Carg, Cc = lpeg.match, lpeg.P, lpeg.S, lpeg.C, lpeg.Carg, lpeg.Cc
-local allocate = utilities.storage.allocate
-local settings_to_array = utilities.parsers.settings_to_array
+local allocate = utilities.storage.allocate
+local settings_to_array = utilities.parsers.settings_to_array
+local variables = interfaces.variables
+local formatters = string.formatters
-local variables = interfaces.variables
-local formatters = string.formatters
-
-local context = context
-local commands = commands
+-- todo: don't flush scripts if no JS key
-local trace_javascript = false trackers.register("backends.javascript", function(v) trace_javascript = v end)
+local trace_javascript = false trackers.register("backends.javascript", function(v) trace_javascript = v end)
local report_javascripts = logs.reporter ("interactions","javascripts")
local status_javascripts = logs.messenger("interactions","javascripts")
-local javascripts = interactions.javascripts or { }
-interactions.javascripts = javascripts
+interactions.javascripts = interactions.javascripts or { }
+local javascripts = interactions.javascripts
-local codes = allocate()
-local preambles = allocate()
-local functions = allocate()
+javascripts.codes = allocate()
+javascripts.preambles = allocate()
+javascripts.functions = allocate()
-javascripts.codes = codes
-javascripts.preambles = preambles
-javascripts.functions = functions
+local codes, preambles, functions = javascripts.codes, javascripts.preambles, javascripts.functions
local preambled = { }
diff --git a/tex/context/base/l-boolean.lua b/tex/context/base/l-boolean.lua
index 8d11080e7..f087f1a4c 100644
--- a/tex/context/base/l-boolean.lua
+++ b/tex/context/base/l-boolean.lua
@@ -59,9 +59,9 @@ end
function string.is_boolean(str,default)
if type(str) == "string" then
- if str == "true" or str == "yes" or str == "on" or str == "t" or str == "1" then
+ if str == "true" or str == "yes" or str == "on" or str == "t" then
return true
- elseif str == "false" or str == "no" or str == "off" or str == "f" or str == "0" then
+ elseif str == "false" or str == "no" or str == "off" or str == "f" then
return false
end
end
diff --git a/tex/context/base/l-dir.lua b/tex/context/base/l-dir.lua
index 40081cc3b..3d0576eeb 100644
--- a/tex/context/base/l-dir.lua
+++ b/tex/context/base/l-dir.lua
@@ -26,8 +26,6 @@ local isfile = lfs.isfile
local currentdir = lfs.currentdir
local chdir = lfs.chdir
-local onwindows = os.type == "windows" or find(os.getenv("PATH"),";")
-
-- in case we load outside luatex
if not isdir then
@@ -138,33 +136,11 @@ end
dir.collectpattern = collectpattern
-local separator
-
-if onwindows then -- we could sanitize here
-
--- pattern = Ct {
--- [1] = (C(P(".") + S("/\\")^1) + C(R("az","AZ") * P(":") * S("/\\")^0) + Cc("./")) * V(2) * V(3),
--- [2] = C(((1-S("*?/\\"))^0 * S("/\\"))^0),
--- [3] = C(P(1)^0)
--- }
-
- local slash = S("/\\") / "/"
-
- pattern = Ct {
- [1] = (Cs(P(".") + slash^1) + Cs(R("az","AZ") * P(":") * slash^0) + Cc("./")) * V(2) * V(3),
- [2] = Cs(((1-S("*?/\\"))^0 * slash)^0),
- [3] = Cs(P(1)^0)
- }
-
-else -- assume unix
-
- pattern = Ct {
- [1] = (C(P(".") + P("/")^1) + Cc("./")) * V(2) * V(3),
- [2] = C(((1-S("*?/"))^0 * P("/"))^0),
- [3] = C(P(1)^0)
- }
-
-end
+local pattern = Ct {
+ [1] = (C(P(".") + P("/")^1) + C(R("az","AZ") * P(":") * P("/")^0) + Cc("./")) * V(2) * V(3),
+ [2] = C(((1-S("*?/"))^0 * P("/"))^0),
+ [3] = C(P(1)^0)
+}
local filter = Cs ( (
P("**") / ".*" +
@@ -281,6 +257,8 @@ end
local make_indeed = true -- false
+local onwindows = os.type == "windows" or find(os.getenv("PATH"),";")
+
if onwindows then
function dir.mkdirs(...)
@@ -295,8 +273,9 @@ if onwindows then
str = str .. "/" .. s
end
end
+ local first, middle, last
local drive = false
- local first, middle, last = match(str,"^(//)(//*)(.*)$")
+ first, middle, last = match(str,"^(//)(//*)(.*)$")
if first then
-- empty network path == local path
else
diff --git a/tex/context/base/l-file.lua b/tex/context/base/l-file.lua
index ebb2b39f4..a64ee8656 100644
--- a/tex/context/base/l-file.lua
+++ b/tex/context/base/l-file.lua
@@ -368,14 +368,11 @@ function file.joinpath(tab,separator) -- table
return tab and concat(tab,separator or io.pathseparator) -- can have trailing //
end
-local someslash = S("\\/")
local stripper = Cs(P(fwslash)^0/"" * reslasher)
-local isnetwork = someslash * someslash * (1-someslash)
- + (1-fwslash-colon)^1 * colon
+local isnetwork = fwslash * fwslash * (1-fwslash) + (1-fwslash-colon)^1 * colon
local isroot = fwslash^1 * -1
local hasroot = fwslash^1
-local reslasher = lpeg.replacer(S("\\/"),"/")
local deslasher = lpeg.replacer(S("\\/")^1,"/")
-- If we have a network or prefix then there is a change that we end up with two
@@ -389,13 +386,8 @@ function file.join(...)
local lst = { ... }
local one = lst[1]
if lpegmatch(isnetwork,one) then
- local one = lpegmatch(reslasher,one)
local two = lpegmatch(deslasher,concat(lst,"/",2))
- if lpegmatch(hasroot,two) then
- return one .. two
- else
- return one .. "/" .. two
- end
+ return one .. "/" .. two
elseif lpegmatch(isroot,one) then
local two = lpegmatch(deslasher,concat(lst,"/",2))
if lpegmatch(hasroot,two) then
@@ -420,8 +412,6 @@ end
-- print(file.join("http://a","/y"))
-- print(file.join("http:///a","/y"))
-- print(file.join("//nas-1","/y"))
--- print(file.join("//nas-1/a/b/c","/y"))
--- print(file.join("\\\\nas-1\\a\\b\\c","\\y"))
-- The previous one fails on "a.b/c" so Taco came up with a split based
-- variant. After some skyping we got it sort of compatible with the old
@@ -431,14 +421,9 @@ end
-- finds were replaced by lpegs.
local drivespec = R("az","AZ")^1 * colon
-local anchors = fwslash
- + drivespec
-local untouched = periods
- + (1-period)^1 * P(-1)
-local mswindrive = Cs(drivespec * (bwslash/"/" + fwslash)^0)
-local mswinuncpath = (bwslash + fwslash) * (bwslash + fwslash) * Cc("//")
-local splitstarter = (mswindrive + mswinuncpath + Cc(false))
- * Ct(lpeg.splitat(S("/\\")^1))
+local anchors = fwslash + drivespec
+local untouched = periods + (1-period)^1 * P(-1)
+local splitstarter = (Cs(drivespec * (bwslash/"/" + fwslash)^0) + Cc(false)) * Ct(lpeg.splitat(S("/\\")^1))
local absolute = fwslash
function file.collapsepath(str,anchor) -- anchor: false|nil, true, "."
@@ -505,7 +490,6 @@ end
-- test("a/./b/..") test("a/aa/../b/bb") test("a/.././././b/..") test("a/./././b/..")
-- test("a/b/c/../..") test("./a/b/c/../..") test("a/b/c/../..")
-- test("./a")
--- test([[\\a.b.c\d\e]])
local validchars = R("az","09","AZ","--","..")
local pattern_a = lpeg.replacer(1-validchars)
diff --git a/tex/context/base/l-io.lua b/tex/context/base/l-io.lua
index 52f166af9..06e1fb5ef 100644
--- a/tex/context/base/l-io.lua
+++ b/tex/context/base/l-io.lua
@@ -35,7 +35,6 @@ local function readall(f)
return f:read('*all')
else
local done = f:seek("set",0)
- local step
if size < 1024*1024 then
step = 1024 * 1024
elseif size > 16*1024*1024 then
@@ -60,7 +59,7 @@ io.readall = readall
function io.loaddata(filename,textmode) -- return nil if empty
local f = io.open(filename,(textmode and 'r') or 'rb')
if f then
- -- local data = f:read('*all')
+-- local data = f:read('*all')
local data = readall(f)
f:close()
if #data > 0 then
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index 399b3ad65..323c73b69 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-lpeg.lua
@@ -13,19 +13,6 @@ if not modules then modules = { } end modules ['l-lpeg'] = {
lpeg = require("lpeg")
--- The latest lpeg doesn't have print any more, and even the new ones are not
--- available by default (only when debug mode is enabled), which is a pitty as
--- as it helps bailign down bottlenecks. Performance seems comparable, although
---
--- local p = lpeg.C(lpeg.P(1)^0 * lpeg.P(-1))
--- local a = string.rep("123",10)
--- lpeg.match(p,a)
---
--- is nearly 20% slower and also still suboptimal (i.e. a match that runs from
--- begin to end, one of the cases where string matchers win).
-
-if not lpeg.print then function lpeg.print(...) print(lpeg.pcode(...)) end end
-
-- tracing (only used when we encounter a problem in integration of lpeg in luatex)
-- some code will move to unicode and string
@@ -82,6 +69,7 @@ setinspector(function(v) if lpegtype(v) then lpegprint(v) return true end end)
lpeg.patterns = lpeg.patterns or { } -- so that we can share
local patterns = lpeg.patterns
+
local anything = P(1)
local endofstring = P(-1)
local alwaysmatched = P(true)
@@ -91,59 +79,37 @@ patterns.endofstring = endofstring
patterns.beginofstring = alwaysmatched
patterns.alwaysmatched = alwaysmatched
-local sign = S('+-')
-local zero = P('0')
-local digit = R('09')
-local octdigit = R("07")
-local lowercase = R("az")
-local uppercase = R("AZ")
-local underscore = P("_")
-local hexdigit = digit + lowercase + uppercase
+local digit, sign = R('09'), S('+-')
local cr, lf, crlf = P("\r"), P("\n"), P("\r\n")
local newline = crlf + S("\r\n") -- cr + lf
local escaped = P("\\") * anything
local squote = P("'")
local dquote = P('"')
local space = P(" ")
-local period = P(".")
-local comma = P(",")
-
-local utfbom_32_be = P('\000\000\254\255') -- 00 00 FE FF
-local utfbom_32_le = P('\255\254\000\000') -- FF FE 00 00
-local utfbom_16_be = P('\254\255') -- FE FF
-local utfbom_16_le = P('\255\254') -- FF FE
-local utfbom_8 = P('\239\187\191') -- EF BB BF
+
+local utfbom_32_be = P('\000\000\254\255')
+local utfbom_32_le = P('\255\254\000\000')
+local utfbom_16_be = P('\255\254')
+local utfbom_16_le = P('\254\255')
+local utfbom_8 = P('\239\187\191')
local utfbom = utfbom_32_be + utfbom_32_le
+ utfbom_16_be + utfbom_16_le
+ utfbom_8
local utftype = utfbom_32_be * Cc("utf-32-be") + utfbom_32_le * Cc("utf-32-le")
+ utfbom_16_be * Cc("utf-16-be") + utfbom_16_le * Cc("utf-16-le")
+ utfbom_8 * Cc("utf-8") + alwaysmatched * Cc("utf-8") -- assume utf8
-local utfstricttype = utfbom_32_be * Cc("utf-32-be") + utfbom_32_le * Cc("utf-32-le")
- + utfbom_16_be * Cc("utf-16-be") + utfbom_16_le * Cc("utf-16-le")
- + utfbom_8 * Cc("utf-8")
local utfoffset = utfbom_32_be * Cc(4) + utfbom_32_le * Cc(4)
+ utfbom_16_be * Cc(2) + utfbom_16_le * Cc(2)
+ utfbom_8 * Cc(3) + Cc(0)
local utf8next = R("\128\191")
-patterns.utfbom_32_be = utfbom_32_be
-patterns.utfbom_32_le = utfbom_32_le
-patterns.utfbom_16_be = utfbom_16_be
-patterns.utfbom_16_le = utfbom_16_le
-patterns.utfbom_8 = utfbom_8
-
-patterns.utf_16_be_nl = P("\000\r\000\n") + P("\000\r") + P("\000\n")
-patterns.utf_16_le_nl = P("\r\000\n\000") + P("\r\000") + P("\n\000")
-
patterns.utf8one = R("\000\127")
patterns.utf8two = R("\194\223") * utf8next
patterns.utf8three = R("\224\239") * utf8next * utf8next
patterns.utf8four = R("\240\244") * utf8next * utf8next * utf8next
patterns.utfbom = utfbom
patterns.utftype = utftype
-patterns.utfstricttype = utfstricttype
patterns.utfoffset = utfoffset
local utf8char = patterns.utf8one + patterns.utf8two + patterns.utf8three + patterns.utf8four
@@ -171,14 +137,29 @@ patterns.nonwhitespace = nonwhitespace
local stripper = spacer^0 * C((spacer^0 * nonspacer^1)^0) -- from example by roberto
------ collapser = Cs(spacer^0/"" * ((spacer^1 * endofstring / "") + (spacer^1/" ") + P(1))^0)
+----- collapser = Cs(spacer^0/"" * ((spacer^1 * P(-1) / "") + (spacer^1/" ") + P(1))^0)
local collapser = Cs(spacer^0/"" * nonspacer^0 * ((spacer^0/" " * nonspacer^1)^0))
patterns.stripper = stripper
patterns.collapser = collapser
-patterns.lowercase = lowercase
-patterns.uppercase = uppercase
+patterns.digit = digit
+patterns.sign = sign
+patterns.cardinal = sign^0 * digit^1
+patterns.integer = sign^0 * digit^1
+patterns.unsigned = digit^0 * P('.') * digit^1
+patterns.float = sign^0 * patterns.unsigned
+patterns.cunsigned = digit^0 * P(',') * digit^1
+patterns.cfloat = sign^0 * patterns.cunsigned
+patterns.number = patterns.float + patterns.integer
+patterns.cnumber = patterns.cfloat + patterns.integer
+patterns.oct = P("0") * R("07")^1
+patterns.octal = patterns.oct
+patterns.HEX = P("0x") * R("09","AF")^1
+patterns.hex = P("0x") * R("09","af")^1
+patterns.hexadecimal = P("0x") * R("09","AF","af")^1
+patterns.lowercase = R("az")
+patterns.uppercase = R("AZ")
patterns.letter = patterns.lowercase + patterns.uppercase
patterns.space = space
patterns.tab = P("\t")
@@ -186,12 +167,12 @@ patterns.spaceortab = patterns.space + patterns.tab
patterns.newline = newline
patterns.emptyline = newline^1
patterns.equal = P("=")
-patterns.comma = comma
-patterns.commaspacer = comma * spacer^0
-patterns.period = period
+patterns.comma = P(",")
+patterns.commaspacer = P(",") * spacer^0
+patterns.period = P(".")
patterns.colon = P(":")
patterns.semicolon = P(";")
-patterns.underscore = underscore
+patterns.underscore = P("_")
patterns.escaped = escaped
patterns.squote = squote
patterns.dquote = dquote
@@ -206,38 +187,12 @@ patterns.singlequoted = squote * patterns.nosquote * squote
patterns.doublequoted = dquote * patterns.nodquote * dquote
patterns.quoted = patterns.doublequoted + patterns.singlequoted
-patterns.digit = digit
-patterns.octdigit = octdigit
-patterns.hexdigit = hexdigit
-patterns.sign = sign
-patterns.cardinal = digit^1
-patterns.integer = sign^-1 * digit^1
-patterns.unsigned = digit^0 * period * digit^1
-patterns.float = sign^-1 * patterns.unsigned
-patterns.cunsigned = digit^0 * comma * digit^1
-patterns.cfloat = sign^-1 * patterns.cunsigned
-patterns.number = patterns.float + patterns.integer
-patterns.cnumber = patterns.cfloat + patterns.integer
-patterns.oct = zero * octdigit^1
-patterns.octal = patterns.oct
-patterns.HEX = zero * P("X") * (digit+uppercase)^1
-patterns.hex = zero * P("x") * (digit+lowercase)^1
-patterns.hexadecimal = zero * S("xX") * hexdigit^1
-
-patterns.hexafloat = sign^-1
- * zero * S("xX")
- * (hexdigit^0 * period * hexdigit^1 + hexdigit^1 * period * hexdigit^0 + hexdigit^1)
- * (S("pP") * sign^-1 * hexdigit^1)^-1
-patterns.decafloat = sign^-1
- * (digit^0 * period * digit^1 + digit^1 * period * digit^0 + digit^1)
- * S("eE") * sign^-1 * digit^1
-
-patterns.propername = (uppercase + lowercase + underscore) * (uppercase + lowercase + underscore + digit)^0 * endofstring
+patterns.propername = R("AZ","az","__") * R("09","AZ","az", "__")^0 * P(-1)
patterns.somecontent = (anything - newline - space)^1 -- (utf8char - newline - space)^1
patterns.beginline = #(1-newline)
-patterns.longtostring = Cs(whitespace^0/"" * ((patterns.quoted + nonwhitespace^1 + whitespace^1/"" * (P(-1) + Cc(" ")))^0))
+patterns.longtostring = Cs(whitespace^0/"" * nonwhitespace^0 * ((whitespace^0/" " * (patterns.quoted + nonwhitespace)^1)^0))
local function anywhere(pattern) --slightly adapted from website
return P { P(pattern) + 1 * V(1) }
@@ -466,10 +421,7 @@ function lpeg.replacer(one,two,makefunction,isutf) -- in principle we should sor
end
end
--- local pattern1 = P(1-P(pattern))^0 * P(pattern) : test for not nil
--- local pattern2 = (P(pattern) * Cc(true) + P(1))^0 : test for true (could be faster, but not much)
-
-function lpeg.finder(lst,makefunction) -- beware: slower than find with 'patternless finds'
+function lpeg.finder(lst,makefunction)
local pattern
if type(lst) == "table" then
pattern = P(false)
@@ -504,8 +456,8 @@ local splitters_f, splitters_s = { }, { }
function lpeg.firstofsplit(separator) -- always return value
local splitter = splitters_f[separator]
if not splitter then
- local pattern = P(separator)
- splitter = C((1 - pattern)^0)
+ separator = P(separator)
+ splitter = C((1 - separator)^0)
splitters_f[separator] = splitter
end
return splitter
@@ -514,35 +466,13 @@ end
function lpeg.secondofsplit(separator) -- nil if not split
local splitter = splitters_s[separator]
if not splitter then
- local pattern = P(separator)
- splitter = (1 - pattern)^0 * pattern * C(anything^0)
- splitters_s[separator] = splitter
- end
- return splitter
-end
-
-local splitters_s, splitters_p = { }, { }
-
-function lpeg.beforesuffix(separator) -- nil if nothing but empty is ok
- local splitter = splitters_s[separator]
- if not splitter then
- local pattern = P(separator)
- splitter = C((1 - pattern)^0) * pattern * endofstring
+ separator = P(separator)
+ splitter = (1 - separator)^0 * separator * C(anything^0)
splitters_s[separator] = splitter
end
return splitter
end
-function lpeg.afterprefix(separator) -- nil if nothing but empty is ok
- local splitter = splitters_p[separator]
- if not splitter then
- local pattern = P(separator)
- splitter = pattern * C(anything^0)
- splitters_p[separator] = splitter
- end
- return splitter
-end
-
function lpeg.balancer(left,right)
left, right = P(left), P(right)
return P { left * ((1 - left - right) + V(1))^0 * right }
@@ -902,9 +832,9 @@ end
-- moved here (before util-str)
------ digit = R("09")
------ period = P(".")
------ zero = P("0")
+local digit = R("09")
+local period = P(".")
+local zero = P("0")
local trailingzeros = zero^0 * -digit -- suggested by Roberto R
local case_1 = period * trailingzeros / ""
local case_2 = period * (digit - trailingzeros)^1 * (trailingzeros / "")
diff --git a/tex/context/base/l-os.lua b/tex/context/base/l-os.lua
index 7f3fd7caf..05ca0acdc 100644
--- a/tex/context/base/l-os.lua
+++ b/tex/context/base/l-os.lua
@@ -127,13 +127,7 @@ function io.popen (...) ioflush() return iopopen(...) end
function os.resultof(command)
local handle = io.popen(command,"r")
- if handle then
- local result = handle:read("*all") or ""
- handle:close()
- return result
- else
- return ""
- end
+ return handle and handle:read("*all") or ""
end
if not io.fileseparator then
@@ -178,21 +172,19 @@ if not os.times then -- ?
end
end
+os.gettimeofday = os.gettimeofday or os.clock
-local gettimeofday = os.gettimeofday or os.clock
-os.gettimeofday = gettimeofday
-
-local startuptime = gettimeofday()
+local startuptime = os.gettimeofday()
function os.runtime()
- return gettimeofday() - startuptime
+ return os.gettimeofday() - startuptime
end
--- print(os.gettimeofday()-os.time())
--- os.sleep(1.234)
--- print (">>",os.runtime())
--- print(os.date("%H:%M:%S",os.gettimeofday()))
--- print(os.date("%H:%M:%S",os.time()))
+--~ print(os.gettimeofday()-os.time())
+--~ os.sleep(1.234)
+--~ print (">>",os.runtime())
+--~ print(os.date("%H:%M:%S",os.gettimeofday()))
+--~ print(os.date("%H:%M:%S",os.time()))
-- no need for function anymore as we have more clever code and helpers now
-- this metatable trickery might as well disappear
@@ -388,43 +380,31 @@ end
local timeformat = format("%%s%s",os.timezone(true))
local dateformat = "!%Y-%m-%d %H:%M:%S"
-local lasttime = nil
-local lastdate = nil
function os.fulltime(t,default)
- t = t and tonumber(t) or 0
+ t = tonumber(t) or 0
if t > 0 then
-- valid time
elseif default then
return default
else
- t = time()
- end
- if t ~= lasttime then
- lasttime = t
- lastdate = format(timeformat,date(dateformat))
+ t = nil
end
- return lastdate
+ return format(timeformat,date(dateformat,t))
end
local dateformat = "%Y-%m-%d %H:%M:%S"
-local lasttime = nil
-local lastdate = nil
function os.localtime(t,default)
- t = t and tonumber(t) or 0
+ t = tonumber(t) or 0
if t > 0 then
-- valid time
elseif default then
return default
else
- t = time()
+ t = nil
end
- if t ~= lasttime then
- lasttime = t
- lastdate = date(dateformat,t)
- end
- return lastdate
+ return date(dateformat,t)
end
function os.converttime(t,default)
@@ -492,60 +472,3 @@ end
-- print(os.which("inkscape"))
-- print(os.which("gs.exe"))
-- print(os.which("ps2pdf"))
-
--- These are moved from core-con.lua (as I needed them elsewhere).
-
-local function isleapyear(year)
- return (year % 400 == 0) or ((year % 100 ~= 0) and (year % 4 == 0))
-end
-
-os.isleapyear = isleapyear
-
--- nicer:
---
--- local days = {
--- [false] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
--- [true] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
--- }
---
--- local function nofdays(year,month)
--- return days[isleapyear(year)][month]
--- return month == 2 and isleapyear(year) and 29 or days[month]
--- end
---
--- more efficient:
-
-local days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
-
-local function nofdays(year,month)
- if not month then
- return isleapyear(year) and 365 or 364
- else
- return month == 2 and isleapyear(year) and 29 or days[month]
- end
-end
-
-os.nofdays = nofdays
-
-function os.weekday(day,month,year)
- return date("%w",time { year = year, month = month, day = day }) + 1
-end
-
-function os.validdate(year,month,day)
- -- we assume that all three values are set
- -- year is always ok, even if lua has a 1970 time limit
- if month < 1 then
- month = 1
- elseif month > 12 then
- month = 12
- end
- if day < 1 then
- day = 1
- else
- local max = nofdays(year,month)
- if day > max then
- day = max
- end
- end
- return year, month, day
-end
diff --git a/tex/context/base/l-package.lua b/tex/context/base/l-package.lua
index 0dbff7c57..579fd3941 100644
--- a/tex/context/base/l-package.lua
+++ b/tex/context/base/l-package.lua
@@ -17,7 +17,7 @@ if not modules then modules = { } end modules ['l-package'] = {
-- -- local mysql = require("luasql.mysql")
local type = type
-local gsub, format, find = string.gsub, string.format, string.find
+local gsub, format = string.gsub, string.format
local P, S, Cs, lpegmatch = lpeg.P, lpeg.S, lpeg.Cs, lpeg.match
@@ -68,7 +68,6 @@ local helpers = package.helpers or {
sequence = {
"already loaded",
"preload table",
- "qualified path", -- beware, lua itself doesn't handle qualified paths (prepends ./)
"lua extra list",
"lib extra list",
"path specification",
@@ -244,23 +243,6 @@ end
helpers.loadedbypath = loadedbypath
-local function loadedbyname(name,rawname)
- if find(name,"^/") or find(name,"^[a-zA-Z]:/") then
- local trace=helpers.trace
- if trace then
- helpers.report("qualified name, identifying '%s'",what,name)
- end
- if isreadable(name) then
- if trace then
- helpers.report("qualified name, '%s' found",what,name)
- end
- return loadfile(name)
- end
- end
-end
-
-helpers.loadedbyname = loadedbyname
-
methods["already loaded"] = function(name)
return package.loaded[name]
end
@@ -269,10 +251,6 @@ methods["preload table"] = function(name)
return builtin["preload table"](name)
end
-methods["qualified path"]=function(name)
- return loadedbyname(addsuffix(lualibfile(name),"lua"),name)
-end
-
methods["lua extra list"] = function(name)
return loadedbypath(addsuffix(lualibfile(name),"lua" ),name,getextraluapaths(),false,"lua")
end
diff --git a/tex/context/base/l-pdfview.lua b/tex/context/base/l-pdfview.lua
index 6302fd6f6..6e0259299 100644
--- a/tex/context/base/l-pdfview.lua
+++ b/tex/context/base/l-pdfview.lua
@@ -6,8 +6,6 @@ if not modules then modules = { } end modules ['l-pdfview'] = {
license = "see context related readme files"
}
--- Todo: add options in cnf file
-
-- Todo: figure out pdfopen/pdfclose on linux. Calling e.g. okular directly
-- doesn't work in linux when issued from scite as it blocks the editor (no
-- & possible or so). Unfortunately pdfopen keeps changing with not keeping
@@ -17,107 +15,62 @@ if not modules then modules = { } end modules ['l-pdfview'] = {
local format, concat = string.format, table.concat
-local report = logs.reporter("pdfview")
-local replace = utilities.templates.replace
-
pdfview = pdfview or { }
-local opencalls -- a table with templates that open a given pdf document
-local closecalls -- a table with templates that close a given pdf document
-local allcalls -- a table with templates that close all open pdf documents
-local runner -- runner function
-local expander -- filename cleanup function
+local opencalls, closecalls, allcalls, runner
--- maybe spawn/execute spec in calls
+-- this might become template based
if os.type == "windows" then
- -- os.setenv("path",os.getenv("path") .. ";" .. "c:/data/system/pdf-xchange")
- -- os.setenv("path",os.getenv("path") .. ";" .. "c:/data/system/sumatrapdf")
-
- -- start is more flexible as it locates binaries in more places and doesn't lock
-
opencalls = {
- ['default'] = [[pdfopen --rxi --file "%filename%"]],
- ['acrobat'] = [[pdfopen --rxi --file "%filename%"]],
- ['fullacrobat'] = [[pdfopen --axi --file "%filename%"]],
- ['okular'] = [[start "test" okular.exe --unique "%filename%"]],
- ['pdfxcview'] = [[start "test" pdfxcview.exe /A "nolock=yes=OpenParameters" "%filename%"]],
- ['sumatra'] = [[start "test" sumatrapdf.exe -reuse-instance -bg-color 0xCCCCCC "%filename%"]],
- ['auto'] = [[start "%filename%"]],
+ ['default'] = "pdfopen --rxi --file",
+ ['acrobat'] = "pdfopen --rxi --file",
+ ['fullacrobat'] = "pdfopen --axi --file",
+ ['okular'] = 'start "test" "c:/data/system/kde/bin/okular.exe" --unique', -- todo!
+ ['sumatra'] = 'start "test" "c:/data/system/sumatrapdf/sumatrapdf.exe" -reuse-instance',
+ ['okular'] = 'start "test" "okular.exe" --unique',
+ ['sumatra'] = 'start "test" "sumatrapdf.exe" -reuse-instance -bg-color 0xCCCCCC',
}
closecalls= {
- ['default'] = [[pdfclose --file "%filename%"]],
- ['acrobat'] = [[pdfclose --file "%filename%"]],
- ['okular'] = false,
- ['pdfxcview'] = false, -- [[pdfxcview.exe /close:discard "%filename%"]],
- ['sumatra'] = false,
- ['auto'] = false,
+ ['default'] = "pdfclose --file",
+ ['acrobat'] = "pdfclose --file",
+ ['okular'] = false,
+ ['sumatra'] = false,
}
allcalls = {
- ['default'] = [[pdfclose --all]],
- ['acrobat'] = [[pdfclose --all]],
- ['okular'] = false,
- ['pdfxcview'] = false,
- ['sumatra'] = false,
- ['auto'] = false,
+ ['default'] = "pdfclose --all",
+ ['acrobat'] = "pdfclose --all",
+ ['okular'] = false,
+ ['sumatra'] = false,
}
- pdfview.method = "acrobat" -- no longer useful due to green pop up line and clashing reader/full
- -- pdfview.method = "pdfxcview"
+ pdfview.method = "acrobat" -- no longer usefull due to green pop up line and clasing reader/full
pdfview.method = "sumatra"
- runner = function(template,variables)
- local cmd = replace(template,variables)
- -- cmd = cmd .. " > /null"
- report("command: %s",cmd)
- os.execute(cmd)
- end
-
- expander = function(name)
- -- We need to avoid issues with chdir to UNC paths and therefore expand
- -- the path when we're current. (We could use one of the helpers instead)
- if file.pathpart(name) == "" then
- return file.collapsepath(file.join(lfs.currentdir(),name))
- else
- return name
- end
+ runner = function(cmd)
+ os.execute(cmd) -- .. " > /null"
end
else
opencalls = {
- ['default'] = [[pdfopen "%filename%"]],
- ['okular'] = [[okular --unique "%filename%"]],
- ['sumatra'] = [[wine "sumatrapdf.exe" -reuse-instance -bg-color 0xCCCCCC "%filename%"]],
- ['pdfxcview'] = [[wine "pdfxcview.exe" /A "nolock=yes=OpenParameters" "%filename%"]],
- ['auto'] = [[open "%filename%"]],
+ ['default'] = "pdfopen", -- we could pass the default here
+ ['okular'] = 'okular --unique'
}
closecalls= {
- ['default'] = [[pdfclose --file "%filename%"]],
- ['okular'] = false,
- ['sumatra'] = false,
- ['auto'] = false,
+ ['default'] = "pdfclose --file",
+ ['okular'] = false,
}
allcalls = {
- ['default'] = [[pdfclose --all]],
- ['okular'] = false,
- ['sumatra'] = false,
- ['auto'] = false,
+ ['default'] = "pdfclose --all",
+ ['okular'] = false,
}
pdfview.method = "okular"
- pdfview.method = "sumatra" -- faster and more complete
- runner = function(template,variables)
- local cmd = replace(template,variables)
- cmd = cmd .. " 1>/dev/null 2>/dev/null &"
- report("command: %s",cmd)
- os.execute(cmd)
- end
-
- expander = function(name)
- return name
+ runner = function(cmd)
+ os.execute(cmd .. " 1>/dev/null 2>/dev/null &")
end
end
@@ -140,6 +93,8 @@ function pdfview.status()
return format("pdfview methods: %s, current method: %s (directives_pdfview_method)",pdfview.methods(),tostring(pdfview.method))
end
+-- local openedfiles = { }
+
local function fullname(name)
return file.addsuffix(name,"pdf")
end
@@ -149,9 +104,10 @@ function pdfview.open(...)
if opencall then
local t = { ... }
for i=1,#t do
- local name = expander(fullname(t[i]))
+ local name = fullname(t[i])
if io.exists(name) then
- runner(opencall,{ filename = name })
+ runner(format('%s "%s"', opencall, name))
+ -- openedfiles[name] = true
end
end
end
@@ -162,10 +118,14 @@ function pdfview.close(...)
if closecall then
local t = { ... }
for i=1,#t do
- local name = expander(fullname(t[i]))
- if io.exists(name) then
- replace(closecall,{ filename = name })
- end
+ local name = fullname(t[i])
+ -- if openedfiles[name] then
+ runner(format('%s "%s"', closecall, name))
+ -- openedfiles[name] = nil
+ -- else
+ -- pdfview.closeall()
+ -- break
+ -- end
end
end
end
@@ -173,8 +133,13 @@ end
function pdfview.closeall()
local allcall = allcalls[pdfview.method]
if allcall then
- runner(allcall)
+ runner(format('%s', allcall))
end
+ -- openedfiles = { }
end
+--~ pdfview.open("t:/document/show-exa.pdf")
+--~ os.sleep(3)
+--~ pdfview.close("t:/document/show-exa.pdf")
+
return pdfview
diff --git a/tex/context/base/l-string.lua b/tex/context/base/l-string.lua
index 9b079b00a..77c076cc5 100644
--- a/tex/context/base/l-string.lua
+++ b/tex/context/base/l-string.lua
@@ -91,8 +91,6 @@ end
local pattern = P(" ")^0 * P(-1)
--- patterns.onlyspaces = pattern
-
function string.is_empty(str)
if str == "" then
return true
diff --git a/tex/context/base/l-table.lua b/tex/context/base/l-table.lua
index 11cb66bef..9a1b97fff 100644
--- a/tex/context/base/l-table.lua
+++ b/tex/context/base/l-table.lua
@@ -16,9 +16,6 @@ local lpegmatch, patterns = lpeg.match, lpeg.patterns
local floor = math.floor
-- extra functions, some might go (when not used)
---
--- we could serialize using %a but that won't work well is in the code we mostly use
--- floats and as such we get unequality e.g. in version comparisons
local stripper = patterns.stripper
@@ -346,7 +343,6 @@ local noquotes, hexify, handle, reduce, compact, inline, functions
local reserved = table.tohash { -- intercept a language inconvenience: no reserved words as key
'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'if',
'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while',
- 'NaN', 'goto',
}
local function simple_table(t)
@@ -367,12 +363,12 @@ local function simple_table(t)
else
tt[nt] = tostring(v) -- tostring not needed
end
+ elseif tv == "boolean" then
+ nt = nt + 1
+ tt[nt] = tostring(v)
elseif tv == "string" then
nt = nt + 1
tt[nt] = format("%q",v)
- elseif tv == "boolean" then
- nt = nt + 1
- tt[nt] = v and "true" or "false"
else
tt = nil
break
@@ -398,8 +394,7 @@ end
-- todo: %g faster on numbers than %s
--- we can speed this up with repeaters and formatters but we haven't defined them
--- yet
+-- we can speed this up with repeaters and formatters (is indeed faster)
local propername = patterns.propername -- was find(name,"^%a[%w%_]*$")
@@ -425,7 +420,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s[%q]={",depth,name))
end
elseif tn == "boolean" then
- handle(format("%s[%s]={",depth,name and "true" or "false"))
+ handle(format("%s[%s]={",depth,tostring(name)))
else
handle(format("%s{",depth))
end
@@ -461,21 +456,21 @@ local function do_serialize(root,name,depth,level,indexed)
--~ if v == root then
-- circular
--~ else
- local tv, tk = type(v), type(k)
+ local t, tk = type(v), type(k)
if compact and first and tk == "number" and k >= first and k <= last then
- if tv == "number" then
+ if t == "number" then
if hexify then
handle(format("%s 0x%04X,",depth,v))
else
handle(format("%s %s,",depth,v)) -- %.99g
end
- elseif tv == "string" then
+ elseif t == "string" then
if reduce and tonumber(v) then
handle(format("%s %s,",depth,v))
else
handle(format("%s %q,",depth,v))
end
- elseif tv == "table" then
+ elseif t == "table" then
if not next(v) then
handle(format("%s {},",depth))
elseif inline then -- and #t > 0
@@ -488,11 +483,11 @@ local function do_serialize(root,name,depth,level,indexed)
else
do_serialize(v,k,depth,level+1,true)
end
- elseif tv == "boolean" then
- handle(format("%s %s,",depth,v and "true" or "false"))
- elseif tv == "function" then
+ elseif t == "boolean" then
+ handle(format("%s %s,",depth,tostring(v)))
+ elseif t == "function" then
if functions then
- handle(format('%s load(%q),',depth,dump(v))) -- maybe strip
+ handle(format('%s load(%q),',depth,dump(v)))
else
handle(format('%s "function",',depth))
end
@@ -503,7 +498,7 @@ local function do_serialize(root,name,depth,level,indexed)
if false then
handle(format("%s __p__=nil,",depth))
end
- elseif tv == "number" then
+ elseif t == "number" then
if tk == "number" then
if hexify then
handle(format("%s [0x%04X]=0x%04X,",depth,k,v))
@@ -512,9 +507,9 @@ local function do_serialize(root,name,depth,level,indexed)
end
elseif tk == "boolean" then
if hexify then
- handle(format("%s [%s]=0x%04X,",depth,k and "true" or "false",v))
+ handle(format("%s [%s]=0x%04X,",depth,tostring(k),v))
else
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v)) -- %.99g
+ handle(format("%s [%s]=%s,",depth,tostring(k),v)) -- %.99g
end
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
if hexify then
@@ -529,7 +524,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%q]=%s,",depth,k,v)) -- %.99g
end
end
- elseif tv == "string" then
+ elseif t == "string" then
if reduce and tonumber(v) then
if tk == "number" then
if hexify then
@@ -538,7 +533,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]=%s,",depth,k,v))
end
elseif tk == "boolean" then
- handle(format("%s [%s]=%s,",depth,k and "true" or "false",v))
+ handle(format("%s [%s]=%s,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s=%s,",depth,k,v))
else
@@ -552,14 +547,14 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]=%q,",depth,k,v))
end
elseif tk == "boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",v))
+ handle(format("%s [%s]=%q,",depth,tostring(k),v))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s=%q,",depth,k,v))
else
handle(format("%s [%q]=%q,",depth,k,v))
end
end
- elseif tv == "table" then
+ elseif t == "table" then
if not next(v) then
if tk == "number" then
if hexify then
@@ -568,7 +563,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]={},",depth,k))
end
elseif tk == "boolean" then
- handle(format("%s [%s]={},",depth,k and "true" or "false"))
+ handle(format("%s [%s]={},",depth,tostring(k)))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s={},",depth,k))
else
@@ -584,7 +579,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]={ %s },",depth,k,concat(st,", ")))
end
elseif tk == "boolean" then
- handle(format("%s [%s]={ %s },",depth,k and "true" or "false",concat(st,", ")))
+ handle(format("%s [%s]={ %s },",depth,tostring(k),concat(st,", ")))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s={ %s },",depth,k,concat(st,", ")))
else
@@ -596,24 +591,24 @@ local function do_serialize(root,name,depth,level,indexed)
else
do_serialize(v,k,depth,level+1)
end
- elseif tv == "boolean" then
+ elseif t == "boolean" then
if tk == "number" then
if hexify then
- handle(format("%s [0x%04X]=%s,",depth,k,v and "true" or "false"))
+ handle(format("%s [0x%04X]=%s,",depth,k,tostring(v)))
else
- handle(format("%s [%s]=%s,",depth,k,v and "true" or "false"))
+ handle(format("%s [%s]=%s,",depth,k,tostring(v)))
end
elseif tk == "boolean" then
- handle(format("%s [%s]=%s,",depth,tostring(k),v and "true" or "false"))
+ handle(format("%s [%s]=%s,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
- handle(format("%s %s=%s,",depth,k,v and "true" or "false"))
+ handle(format("%s %s=%s,",depth,k,tostring(v)))
else
- handle(format("%s [%q]=%s,",depth,k,v and "true" or "false"))
+ handle(format("%s [%q]=%s,",depth,k,tostring(v)))
end
- elseif tv == "function" then
+ elseif t == "function" then
if functions then
- local f = getinfo(v).what == "C" and dump(dummy) or dump(v) -- maybe strip
- -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v) -- maybe strip
+ local f = getinfo(v).what == "C" and dump(dummy) or dump(v)
+ -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v)
if tk == "number" then
if hexify then
handle(format("%s [0x%04X]=load(%q),",depth,k,f))
@@ -621,7 +616,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]=load(%q),",depth,k,f))
end
elseif tk == "boolean" then
- handle(format("%s [%s]=load(%q),",depth,k and "true" or "false",f))
+ handle(format("%s [%s]=load(%q),",depth,tostring(k),f))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s=load(%q),",depth,k,f))
else
@@ -636,7 +631,7 @@ local function do_serialize(root,name,depth,level,indexed)
handle(format("%s [%s]=%q,",depth,k,tostring(v)))
end
elseif tk == "boolean" then
- handle(format("%s [%s]=%q,",depth,k and "true" or "false",tostring(v)))
+ handle(format("%s [%s]=%q,",depth,tostring(k),tostring(v)))
elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
handle(format("%s %s=%q,",depth,k,tostring(v)))
else
@@ -718,10 +713,321 @@ local function serialize(_handle,root,name,specification) -- handle wins
handle("}")
end
--- A version with formatters is some 20% faster than using format (because formatters are
--- much faster) but of course, inlining the format using .. is then again faster .. anyway,
--- as we do some pretty printing as well there is not that much to gain unless we make a
--- 'fast' ugly variant as well. But, we would have to move the formatter to l-string then.
+-- -- This is some 20% faster than using format (because formatters are much faster) but
+-- -- of course, inlining the format using .. is then again faster .. anyway, as we do
+-- -- some pretty printing as well there is not that much to gain unless we make a 'fast'
+-- -- ugly variant as well. But, we would have to move the formatter to l-string then.
+
+-- local formatters = string.formatters
+
+-- local function do_serialize(root,name,level,indexed)
+-- if level > 0 then
+-- if indexed then
+-- handle(formatters["%w{"](level))
+-- else
+-- local tn = type(name)
+-- if tn == "number" then
+-- if hexify then
+-- handle(formatters["%w[%04H]={"](level,name))
+-- else
+-- handle(formatters["%w[%s]={"](level,name))
+-- end
+-- elseif tn == "string" then
+-- if noquotes and not reserved[name] and lpegmatch(propername,name) then
+-- handle(formatters["%w%s={"](level,name))
+-- else
+-- handle(formatters["%w[%q]={"](level,name))
+-- end
+-- elseif tn == "boolean" then
+-- handle(formatters["%w[%S]={"](level,name))
+-- else
+-- handle(formatters["%w{"](level))
+-- end
+-- end
+-- end
+-- -- we could check for k (index) being number (cardinal)
+-- if root and next(root) then
+-- -- local first, last = nil, 0 -- #root cannot be trusted here (will be ok in 5.2 when ipairs is gone)
+-- -- if compact then
+-- -- -- NOT: for k=1,#root do (we need to quit at nil)
+-- -- for k,v in ipairs(root) do -- can we use next?
+-- -- if not first then first = k end
+-- -- last = last + 1
+-- -- end
+-- -- end
+-- local first, last = nil, 0
+-- if compact then
+-- last = #root
+-- for k=1,last do
+-- if root[k] == nil then
+-- last = k - 1
+-- break
+-- end
+-- end
+-- if last > 0 then
+-- first = 1
+-- end
+-- end
+-- local sk = sortedkeys(root)
+-- for i=1,#sk do
+-- local k = sk[i]
+-- local v = root[k]
+-- --~ if v == root then
+-- -- circular
+-- --~ else
+-- local t, tk = type(v), type(k)
+-- if compact and first and tk == "number" and k >= first and k <= last then
+-- if t == "number" then
+-- if hexify then
+-- handle(formatters["%w %04H,"](level,v))
+-- else
+-- handle(formatters["%w %s,"](level,v)) -- %.99g
+-- end
+-- elseif t == "string" then
+-- if reduce and tonumber(v) then
+-- handle(formatters["%w %s,"](level,v))
+-- else
+-- handle(formatters["%w %q,"](level,v))
+-- end
+-- elseif t == "table" then
+-- if not next(v) then
+-- handle(formatters["%w {},"](level))
+-- elseif inline then -- and #t > 0
+-- local st = simple_table(v)
+-- if st then
+-- handle(formatters["%w { %, t },"](level,st))
+-- else
+-- do_serialize(v,k,level+1,true)
+-- end
+-- else
+-- do_serialize(v,k,level+1,true)
+-- end
+-- elseif t == "boolean" then
+-- handle(formatters["%w %S,"](level,v))
+-- elseif t == "function" then
+-- if functions then
+-- handle(formatters['%w load(%q),'](level,dump(v)))
+-- else
+-- handle(formatters['%w "function",'](level))
+-- end
+-- else
+-- handle(formatters["%w %Q,"](level,v))
+-- end
+-- elseif k == "__p__" then -- parent
+-- if false then
+-- handle(formatters["%w __p__=nil,"](level))
+-- end
+-- elseif t == "number" then
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=%04H,"](level,k,v))
+-- else
+-- handle(formatters["%w [%s]=%s,"](level,k,v)) -- %.99g
+-- end
+-- elseif tk == "boolean" then
+-- if hexify then
+-- handle(formatters["%w [%S]=%04H,"](level,k,v))
+-- else
+-- handle(formatters["%w [%S]=%s,"](level,k,v)) -- %.99g
+-- end
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- if hexify then
+-- handle(formatters["%w %s=%04H,"](level,k,v))
+-- else
+-- handle(formatters["%w %s=%s,"](level,k,v)) -- %.99g
+-- end
+-- else
+-- if hexify then
+-- handle(formatters["%w [%q]=%04H,"](level,k,v))
+-- else
+-- handle(formatters["%w [%q]=%s,"](level,k,v)) -- %.99g
+-- end
+-- end
+-- elseif t == "string" then
+-- if reduce and tonumber(v) then
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=%s,"](level,k,v))
+-- else
+-- handle(formatters["%w [%s]=%s,"](level,k,v))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]=%s,"](level,k,v))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s=%s,"](level,k,v))
+-- else
+-- handle(formatters["%w [%q]=%s,"](level,k,v))
+-- end
+-- else
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=%q,"](level,k,v))
+-- else
+-- handle(formatters["%w [%s]=%q,"](level,k,v))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]=%q,"](level,k,v))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s=%q,"](level,k,v))
+-- else
+-- handle(formatters["%w [%q]=%q,"](level,k,v))
+-- end
+-- end
+-- elseif t == "table" then
+-- if not next(v) then
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]={},"](level,k))
+-- else
+-- handle(formatters["%w [%s]={},"](level,k))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]={},"](level,k))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s={},"](level,k))
+-- else
+-- handle(formatters["%w [%q]={},"](level,k))
+-- end
+-- elseif inline then
+-- local st = simple_table(v)
+-- if st then
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]={ %, t },"](level,k,st))
+-- else
+-- handle(formatters["%w [%s]={ %, t },"](level,k,st))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]={ %, t },"](level,k,st))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s={ %, t },"](level,k,st))
+-- else
+-- handle(formatters["%w [%q]={ %, t },"](level,k,st))
+-- end
+-- else
+-- do_serialize(v,k,level+1)
+-- end
+-- else
+-- do_serialize(v,k,level+1)
+-- end
+-- elseif t == "boolean" then
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=%S,"](level,k,v))
+-- else
+-- handle(formatters["%w [%s]=%S,"](level,k,v))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]=%S,"](level,k,v))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s=%S,"](level,k,v))
+-- else
+-- handle(formatters["%w [%q]=%S,"](level,k,v))
+-- end
+-- elseif t == "function" then
+-- if functions then
+-- local f = getinfo(v).what == "C" and dump(dummy) or dump(v)
+-- -- local f = getinfo(v).what == "C" and dump(function(...) return v(...) end) or dump(v)
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=load(%q),"](level,k,f))
+-- else
+-- handle(formatters["%w [%s]=load(%q),"](level,k,f))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]=load(%q),"](level,k,f))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s=load(%q),"](level,k,f))
+-- else
+-- handle(formatters["%w [%q]=load(%q),"](level,k,f))
+-- end
+-- end
+-- else
+-- if tk == "number" then
+-- if hexify then
+-- handle(formatters["%w [%04H]=%Q,"](level,k,v))
+-- else
+-- handle(formatters["%w [%s]=%Q,"](level,k,v))
+-- end
+-- elseif tk == "boolean" then
+-- handle(formatters["%w [%S]=%Q,"](level,k,v))
+-- elseif noquotes and not reserved[k] and lpegmatch(propername,k) then
+-- handle(formatters["%w %s=%Q,"](level,k,v))
+-- else
+-- handle(formatters["%w [%q]=%Q,"](level,k,v))
+-- end
+-- end
+-- --~ end
+-- end
+-- end
+-- if level > 0 then
+-- handle(formatters["%w}"](level))
+-- end
+-- end
+
+-- local function serialize(_handle,root,name,specification) -- handle wins
+-- local tname = type(name)
+-- if type(specification) == "table" then
+-- noquotes = specification.noquotes
+-- hexify = specification.hexify
+-- handle = _handle or specification.handle or print
+-- reduce = specification.reduce or false
+-- functions = specification.functions
+-- compact = specification.compact
+-- inline = specification.inline and compact
+-- if functions == nil then
+-- functions = true
+-- end
+-- if compact == nil then
+-- compact = true
+-- end
+-- if inline == nil then
+-- inline = compact
+-- end
+-- else
+-- noquotes = false
+-- hexify = false
+-- handle = _handle or print
+-- reduce = false
+-- compact = true
+-- inline = true
+-- functions = true
+-- end
+-- if tname == "string" then
+-- if name == "return" then
+-- handle("return {")
+-- else
+-- handle(name .. "={")
+-- end
+-- elseif tname == "number" then
+-- if hexify then
+-- handle(format("[0x%04X]={",name))
+-- else
+-- handle("[" .. name .. "]={")
+-- end
+-- elseif tname == "boolean" then
+-- if name then
+-- handle("return {")
+-- else
+-- handle("{")
+-- end
+-- else
+-- handle("t={")
+-- end
+-- if root then
+-- -- The dummy access will initialize a table that has a delayed initialization
+-- -- using a metatable. (maybe explicitly test for metatable)
+-- if getmetatable(root) then -- todo: make this an option, maybe even per subtable
+-- local dummy = root._w_h_a_t_e_v_e_r_
+-- root._w_h_a_t_e_v_e_r_ = nil
+-- end
+-- -- Let's forget about empty tables.
+-- if next(root) then
+-- do_serialize(root,name,0)
+-- end
+-- end
+-- handle("}")
+-- end
-- name:
--
diff --git a/tex/context/base/l-unicode.lua b/tex/context/base/l-unicode.lua
index 7ada394d5..813ffd54b 100644
--- a/tex/context/base/l-unicode.lua
+++ b/tex/context/base/l-unicode.lua
@@ -25,7 +25,7 @@ utf.values = utf.values or string.utfvalues
-- string.bytepairs
local type = type
-local char, byte, format, sub, gmatch = string.char, string.byte, string.format, string.sub, string.gmatch
+local char, byte, format, sub = string.char, string.byte, string.format, string.sub
local concat = table.concat
local P, C, R, Cs, Ct, Cmt, Cc, Carg, Cp = lpeg.P, lpeg.C, lpeg.R, lpeg.Cs, lpeg.Ct, lpeg.Cmt, lpeg.Cc, lpeg.Carg, lpeg.Cp
local lpegmatch, patterns = lpeg.match, lpeg.patterns
@@ -38,14 +38,13 @@ local replacer = lpeg.replacer
local utfvalues = utf.values
local utfgmatch = utf.gmatch -- not always present
-local p_utftype = patterns.utftype
-local p_utfstricttype = patterns.utfstricttype
-local p_utfoffset = patterns.utfoffset
-local p_utf8char = patterns.utf8char
-local p_utf8byte = patterns.utf8byte
-local p_utfbom = patterns.utfbom
-local p_newline = patterns.newline
-local p_whitespace = patterns.whitespace
+local p_utftype = patterns.utftype
+local p_utfoffset = patterns.utfoffset
+local p_utf8char = patterns.utf8char
+local p_utf8byte = patterns.utf8byte
+local p_utfbom = patterns.utfbom
+local p_newline = patterns.newline
+local p_whitespace = patterns.whitespace
if not unicode then
@@ -622,273 +621,116 @@ function utf.magic(f) -- not used
return lpegmatch(p_utftype,str)
end
-local utf16_to_utf8_be, utf16_to_utf8_le
-local utf32_to_utf8_be, utf32_to_utf8_le
-
-local utf_16_be_linesplitter = patterns.utfbom_16_be^-1 * lpeg.tsplitat(patterns.utf_16_be_nl)
-local utf_16_le_linesplitter = patterns.utfbom_16_le^-1 * lpeg.tsplitat(patterns.utf_16_le_nl)
-
--- we have three possibilities:
-
--- bytepairs: 0.048
--- gmatch : 0.069
--- lpeg : 0.089 (match time captures)
-
-if bytepairs then
-
- -- with a little bit more code we could include the linesplitter
-
- utf16_to_utf8_be = function(t)
- if type(t) == "string" then
- t = lpegmatch(utf_16_be_linesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, 0
- for left, right in bytepairs(t[i]) do
- if right then
- local now = 256*left + right
- if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- more = 0
- r = r + 1
- result[r] = utfchar(now)
- elseif now >= 0xD800 and now <= 0xDBFF then
- more = now
- else
- r = r + 1
- result[r] = utfchar(now)
- end
- end
- end
- t[i] = concat(result,"",1,r) -- we reused tmp, hence t
- end
- return t
- end
-
- utf16_to_utf8_le = function(t)
- if type(t) == "string" then
- t = lpegmatch(utf_16_le_linesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, 0
- for left, right in bytepairs(t[i]) do
- if right then
- local now = 256*right + left
- if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- more = 0
- r = r + 1
- result[r] = utfchar(now)
- elseif now >= 0xD800 and now <= 0xDBFF then
- more = now
- else
- r = r + 1
- result[r] = utfchar(now)
- end
- end
- end
- t[i] = concat(result,"",1,r) -- we reused tmp, hence t
- end
- return t
+local function utf16_to_utf8_be(t)
+ if type(t) == "string" then
+ t = lpegmatch(utflinesplitter,t)
end
-
- utf32_to_utf8_be = function(t)
- if type(t) == "string" then
- t = lpegmatch(utflinesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, -1
- for a,b in bytepairs(t[i]) do
- if a and b then
- if more < 0 then
- more = 256*256*256*a + 256*256*b
- else
- r = r + 1
- result[t] = utfchar(more + 256*a + b)
- more = -1
- end
+ local result = { } -- we reuse result
+ for i=1,#t do
+ local r, more = 0, 0
+ for left, right in bytepairs(t[i]) do
+ if right then
+ local now = 256*left + right
+ if more > 0 then
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+ more = 0
+ r = r + 1
+ result[r] = utfchar(now)
+ elseif now >= 0xD800 and now <= 0xDBFF then
+ more = now
else
- break
+ r = r + 1
+ result[r] = utfchar(now)
end
end
- t[i] = concat(result,"",1,r)
end
- return t
+ t[i] = concat(result,"",1,r) -- we reused tmp, hence t
end
+ return t
+end
- utf32_to_utf8_le = function(t)
- if type(t) == "string" then
- t = lpegmatch(utflinesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, -1
- for a,b in bytepairs(t[i]) do
- if a and b then
- if more < 0 then
- more = 256*b + a
- else
- r = r + 1
- result[t] = utfchar(more + 256*256*256*b + 256*256*a)
- more = -1
- end
+local function utf16_to_utf8_le(t)
+ if type(t) == "string" then
+ t = lpegmatch(utflinesplitter,t)
+ end
+ local result = { } -- we reuse result
+ for i=1,#t do
+ local r, more = 0, 0
+ for left, right in bytepairs(t[i]) do
+ if right then
+ local now = 256*right + left
+ if more > 0 then
+ now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
+ more = 0
+ r = r + 1
+ result[r] = utfchar(now)
+ elseif now >= 0xD800 and now <= 0xDBFF then
+ more = now
else
- break
+ r = r + 1
+ result[r] = utfchar(now)
end
end
- t[i] = concat(result,"",1,r)
end
- return t
+ t[i] = concat(result,"",1,r) -- we reused tmp, hence t
end
+ return t
+end
-else
-
- utf16_to_utf8_be = function(t)
- if type(t) == "string" then
- t = lpegmatch(utf_16_be_linesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, 0
- for left, right in gmatch(t[i],"(.)(.)") do
- if left == "\000" then -- experiment
+local function utf32_to_utf8_be(t)
+ if type(t) == "string" then
+ t = lpegmatch(utflinesplitter,t)
+ end
+ local result = { } -- we reuse result
+ for i=1,#t do
+ local r, more = 0, -1
+ for a,b in bytepairs(t[i]) do
+ if a and b then
+ if more < 0 then
+ more = 256*256*256*a + 256*256*b
+ else
r = r + 1
- result[r] = utfchar(byte(right))
- elseif right then
- local now = 256*byte(left) + byte(right)
- if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- more = 0
- r = r + 1
- result[r] = utfchar(now)
- elseif now >= 0xD800 and now <= 0xDBFF then
- more = now
- else
- r = r + 1
- result[r] = utfchar(now)
- end
+ result[t] = utfchar(more + 256*a + b)
+ more = -1
end
+ else
+ break
end
- t[i] = concat(result,"",1,r) -- we reused tmp, hence t
end
- return t
+ t[i] = concat(result,"",1,r)
end
+ return t
+end
- utf16_to_utf8_le = function(t)
- if type(t) == "string" then
- t = lpegmatch(utf_16_le_linesplitter,t)
- end
- local result = { } -- we reuse result
- for i=1,#t do
- local r, more = 0, 0
- for left, right in gmatch(t[i],"(.)(.)") do
- if right == "\000" then
+local function utf32_to_utf8_le(t)
+ if type(t) == "string" then
+ t = lpegmatch(utflinesplitter,t)
+ end
+ local result = { } -- we reuse result
+ for i=1,#t do
+ local r, more = 0, -1
+ for a,b in bytepairs(t[i]) do
+ if a and b then
+ if more < 0 then
+ more = 256*b + a
+ else
r = r + 1
- result[r] = utfchar(byte(left))
- elseif right then
- local now = 256*byte(right) + byte(left)
- if more > 0 then
- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- more = 0
- r = r + 1
- result[r] = utfchar(now)
- elseif now >= 0xD800 and now <= 0xDBFF then
- more = now
- else
- r = r + 1
- result[r] = utfchar(now)
- end
+ result[t] = utfchar(more + 256*256*256*b + 256*256*a)
+ more = -1
end
+ else
+ break
end
- t[i] = concat(result,"",1,r) -- we reused tmp, hence t
end
- return t
+ t[i] = concat(result,"",1,r)
end
-
- utf32_to_utf8_le = function() return { } end -- never used anyway
- utf32_to_utf8_be = function() return { } end -- never used anyway
-
- -- the next one is slighty slower
-
- -- local result, lines, r, more = { }, { }, 0, 0
- --
- -- local simple = Cmt(
- -- C(1) * C(1), function(str,p,left,right)
- -- local now = 256*byte(left) + byte(right)
- -- if more > 0 then
- -- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- -- more = 0
- -- r = r + 1
- -- result[r] = utfchar(now)
- -- elseif now >= 0xD800 and now <= 0xDBFF then
- -- more = now
- -- else
- -- r = r + 1
- -- result[r] = utfchar(now)
- -- end
- -- return p
- -- end
- -- )
- --
- -- local complex = Cmt(
- -- C(1) * C(1), function(str,p,left,right)
- -- local now = 256*byte(left) + byte(right)
- -- if more > 0 then
- -- now = (more-0xD800)*0x400 + (now-0xDC00) + 0x10000 -- the 0x10000 smells wrong
- -- more = 0
- -- r = r + 1
- -- result[r] = utfchar(now)
- -- elseif now >= 0xD800 and now <= 0xDBFF then
- -- more = now
- -- else
- -- r = r + 1
- -- result[r] = utfchar(now)
- -- end
- -- return p
- -- end
- -- )
- --
- -- local lineend = Cmt (
- -- patterns.utf_16_be_nl, function(str,p)
- -- lines[#lines+1] = concat(result,"",1,r)
- -- r, more = 0, 0
- -- return p
- -- end
- -- )
- --
- -- local be_1 = patterns.utfbom_16_be^-1 * (simple + complex)^0
- -- local be_2 = patterns.utfbom_16_be^-1 * (lineend + simple + complex)^0
- --
- -- utf16_to_utf8_be = function(t)
- -- if type(t) == "string" then
- -- local s = t
- -- lines, r, more = { }, 0, 0
- -- lpegmatch(be_2,s)
- -- if r > 0 then
- -- lines[#lines+1] = concat(result,"",1,r)
- -- end
- -- result = { }
- -- return lines
- -- else
- -- for i=1,#t do
- -- r, more = 0, 0
- -- lpegmatch(be_1,t[i])
- -- t[i] = concat(result,"",1,r)
- -- end
- -- result = { }
- -- return t
- -- end
- -- end
-
+ return t
end
-utf.utf16_to_utf8_le = utf16_to_utf8_le
-utf.utf16_to_utf8_be = utf16_to_utf8_be
-utf.utf32_to_utf8_le = utf32_to_utf8_le
utf.utf32_to_utf8_be = utf32_to_utf8_be
+utf.utf32_to_utf8_le = utf32_to_utf8_le
+utf.utf16_to_utf8_be = utf16_to_utf8_be
+utf.utf16_to_utf8_le = utf16_to_utf8_le
function utf.utf8_to_utf8(t)
return type(t) == "string" and lpegmatch(utflinesplitter,t) or t
@@ -935,19 +777,11 @@ end
local _, l_remap = utf.remapper(little)
local _, b_remap = utf.remapper(big)
-function utf.utf8_to_utf16_be(str)
- return char(254,255) .. lpegmatch(b_remap,str)
-end
-
-function utf.utf8_to_utf16_le(str)
- return char(255,254) .. lpegmatch(l_remap,str)
-end
-
function utf.utf8_to_utf16(str,littleendian)
if littleendian then
- return utf.utf8_to_utf16_le(str)
+ return char(255,254) .. lpegmatch(l_remap,str)
else
- return utf.utf8_to_utf16_be(str)
+ return char(254,255) .. lpegmatch(b_remap,str)
end
end
@@ -977,22 +811,6 @@ function utf.xstring(s)
return format("0x%05X",type(s) == "number" and s or utfbyte(s))
end
-function utf.toeight(str)
- if not str then
- return nil
- end
- local utftype = lpegmatch(p_utfstricttype,str)
- if utftype == "utf-8" then
- return sub(str,4)
- elseif utftype == "utf-16-le" then
- return utf16_to_utf8_le(str)
- elseif utftype == "utf-16-be" then
- return utf16_to_utf8_ne(str)
- else
- return str
- end
-end
-
--
local p_nany = p_utf8char / ""
diff --git a/tex/context/base/l-url.lua b/tex/context/base/l-url.lua
index 7b7910fa7..4624a0507 100644
--- a/tex/context/base/l-url.lua
+++ b/tex/context/base/l-url.lua
@@ -79,18 +79,12 @@ setmetatable(escapes, { __index = function(t,k)
return v
end })
-local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most
-local unescaper = Cs((escapedchar + 1)^0)
-local getcleaner = Cs((P("+++") / "%%2B" + P("+") / "%%20" + P(1))^1)
+local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most
+local unescaper = Cs((escapedchar + 1)^0)
-lpegpatterns.urlunescaped = escapedchar
-lpegpatterns.urlescaper = escaper
-lpegpatterns.urlunescaper = unescaper
-lpegpatterns.urlgetcleaner = getcleaner
-
-function url.unescapeget(str)
- return lpegmatch(getcleaner,str)
-end
+lpegpatterns.urlunescaped = escapedchar
+lpegpatterns.urlescaper = escaper
+lpegpatterns.urlunescaper = unescaper
-- todo: reconsider Ct as we can as well have five return values (saves a table)
-- so we can have two parsers, one with and one without
diff --git a/tex/context/base/lang-def.mkiv b/tex/context/base/lang-def.mkiv
index ecd5b3c22..9f84e90f0 100644
--- a/tex/context/base/lang-def.mkiv
+++ b/tex/context/base/lang-def.mkiv
@@ -219,9 +219,10 @@
\c!rightquote=\upperrightsinglesixquote,
\c!leftquotation=\lowerleftdoubleninequote,
\c!rightquotation=\upperrightdoublesixquote,
- \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year},
+ \c!date={\v!day,\fourperemspace,\v!month,\space,\v!year}
\s!lefthyphenmin=2,
- \s!righthyphenmin=3]
+ \s!righthyphenmin=3
+]
\installlanguage
[\s!sk]
@@ -234,9 +235,10 @@
\c!rightquote=\upperrightsinglesixquote,
\c!leftquotation=\lowerleftdoubleninequote,
\c!rightquotation=\upperrightdoublesixquote,
- \c!date={\v!day,{.\fourperemspace},\v!month,\space,\v!year},
+ \c!date={\v!day,\fourperemspace,\v!month,\space,\v!year}
\s!lefthyphenmin=2,
- \s!righthyphenmin=3]
+ \s!righthyphenmin=3
+]
\installlanguage
[\s!hr]
@@ -269,7 +271,7 @@
\installlanguage [\s!slovak] [\s!sk]
\installlanguage [\s!croatian] [\s!hr]
\installlanguage [\s!slovenian] [\s!sl]
-\installlanguage [slovene] [\s!sl] % both possible (mojca: still needed?)
+\installlanguage [slovene] [\s!sl] % both possible (mojca: still needed?)
\def\doconvertsloveniancharacters{\dodoconvertcharacters{25}}
@@ -398,7 +400,7 @@
\c!rightquote=\upperrightsingleninequote,
\c!leftquotation=\upperleftdoublesixquote,
\c!rightquotation=\upperrightdoubleninequote,
- \c!date={\v!year,\space,\v!month,\space,\v!day},
+ \c!date={\v!year,\space,\v!month,\space,\v!day}
\s!patterns=\s!tk,
\s!lefthyphenmin=1,
\s!righthyphenmin=2]
diff --git a/tex/context/base/lang-ini.mkiv b/tex/context/base/lang-ini.mkiv
index 17d00033b..1297fe23e 100644
--- a/tex/context/base/lang-ini.mkiv
+++ b/tex/context/base/lang-ini.mkiv
@@ -374,24 +374,15 @@
\fi
\lang_basics_synchronize_min_max}
-% \unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application
-% {\ifx\dohyphens\relax
-% \unexpanded\edef\dohyphens
-% {\hyphenpenalty \the\hyphenpenalty
-% \exhyphenpenalty\the\exhyphenpenalty
-% \relax}%
-% \fi
-% \hyphenpenalty \plustenthousand
-% \exhyphenpenalty\plustenthousand}
-
-\unexpanded\def\nohyphens % nicer for url's
+\unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application
{\ifx\dohyphens\relax
\unexpanded\edef\dohyphens
- {\hyphenminoffset\the\hyphenminoffset\relax
- \lang_basics_synchronize_min_max}%
+ {\hyphenpenalty \the\hyphenpenalty
+ \exhyphenpenalty\the\exhyphenpenalty
+ \relax}%
\fi
- \hyphenminoffset\plusthousand
- \lang_basics_synchronize_min_max}
+ \hyphenpenalty \plustenthousand
+ \exhyphenpenalty\plustenthousand}
\let\dohyphens\relax
@@ -501,10 +492,6 @@
\fi
\mainlanguagenumber\normallanguage}
-\appendtoks
- \normallanguage\mainlanguagenumber
-\to \everybeforepagebody
-
%D New (see nomarking and nolist):
\def\splitsequence#1#2%
diff --git a/tex/context/base/lang-rep.lua b/tex/context/base/lang-rep.lua
deleted file mode 100644
index 31ae36e6d..000000000
--- a/tex/context/base/lang-rep.lua
+++ /dev/null
@@ -1,189 +0,0 @@
-if not modules then modules = { } end modules ['lang-rep'] = {
- version = 1.001,
- comment = "companion to lang-rep.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- A BachoTeX 2013 experiment, probably not that useful. Eventually I used a simpler
--- more generic example.
-
-local utfbyte, utfsplit = utf.byte, utf.split
-
-local trace_replacements = false trackers.register("languages.replacements", function(v) trace_replacements = v end)
-local trace_detail = false trackers.register("languages.replacements.detail", function(v) trace_detail = v end)
-
-local report_replacement = logs.reporter("languages","replacements")
-
-local glyph_code = nodes.nodecodes.glyph
-
-local insert_node_before = nodes.insert_before
-local remove_node = nodes.remove
-local copy_node = nodes.copy
-
-local texsetattribute = tex.setattribute
-local unsetvalue = attributes.unsetvalue
-
-local v_reset = interfaces.variables.reset
-
-local replacements = languages.replacements or { }
-languages.replacements = replacements
-
-local a_replacements = attributes.private("replacements")
-
-local lists = { }
-local last = 0
-local trees = { }
-
-table.setmetatableindex(lists,function(lists,name)
- last = last + 1
- local list = { }
- local data = { name = name, list = list, attribute = last }
- lists[last] = data
- lists[name] = data
- trees[last] = list
- return data
-end)
-
-local function add(root,word,replacement)
- local list = utfsplit(word,true)
- for i=1,#list do
- local l = utfbyte(list[i])
- if not root[l] then
- root[l] = { }
- end
- if i == #list then
- local newlist = utfsplit(replacement,true)
- for i=1,#newlist do
- newlist[i] = utfbyte(newlist[i])
- end
- root[l].final = {
- word = word,
- replacement = replacement,
- oldlength = #list,
- newcodes = newlist,
- }
- end
- root = root[l]
- end
-end
-
-function replacements.add(category,word,replacement)
- local root = lists[category].list
- if type(word) == "table" then
- for word, replacement in next, word do
- add(root,word,replacement)
- end
- else
- add(root,word,replacement or "")
- end
-end
-
-local function hit(a,head)
- local tree = trees[a]
- if tree then
- local root = tree[head.char]
- if root then
- local current = head.next
- local lastrun = false
- local lastfinal = false
- while current and current.id == glyph_code do
- local newroot = root[current.char]
- if not newroot then
- return lastrun, lastfinal
- else
- local final = newroot.final
- if final then
- if trace_detail then
- report_replacement("hitting word %a, replacement %a",final.word,final.replacement)
- end
- lastrun = current
- lastfinal = final
- else
- root = newroot
- end
- end
- current = current.next
- end
- if lastrun then
- return lastrun, lastfinal
- end
- end
- end
-end
-
-function replacements.handler(head)
- local current = head
- local done = false
- while current do
- if current.id == glyph_code then
- local a = getattr(current,a_replacements)
- if a then
- local last, final = hit(a,current)
- if last then
- local oldlength = final.oldlength
- local newcodes = final.newcodes
- local newlength = #newcodes
- if report_replacement then
- report_replacement("replacing word %a by %a",final.word,final.replacement)
- end
- if oldlength == newlength then -- #old == #new
- for i=1,newlength do
- current.char = newcodes[i]
- current = current.next
- end
- elseif oldlength < newlength then -- #old < #new
- for i=1,newlength-oldlength do
- local n = copy_node(current)
- n.char = newcodes[i]
- head, current = insert_node_before(head,current,n)
- current = current.next
- end
- for i=newlength-oldlength+1,newlength do
- current.char = newcodes[i]
- current = current.next
- end
- else -- #old > #new
- for i=1,oldlength-newlength do
- head, current = remove_node(head,current,true)
- end
- for i=1,newlength do
- current.char = newcodes[i]
- current = current.next
- end
- end
- done = true
- end
- end
- end
- current = current.next
- end
- return head, done
-end
-
-local enabled = false
-
-function replacements.set(n) -- number or 'reset'
- if n == v_reset then
- n = unsetvalue
- else
- n = lists[n].attribute
- if not enabled then
- nodes.tasks.enableaction("processors","languages.replacements.handler")
- if trace_replacements then
- report_replacement("enabling replacement handler")
- end
- enabled = true
- end
- end
- texsetattribute(a_replacements,n)
-end
-
--- interface
-
-commands.setreplacements = replacements.set
-commands.addreplacements = replacements.add
-
-nodes.tasks.prependaction("processors","words","languages.replacements.handler")
-nodes.tasks.disableaction("processors","languages.replacements.handler")
diff --git a/tex/context/base/lang-url.lua b/tex/context/base/lang-url.lua
index 4ed5cdea1..35381e672 100644
--- a/tex/context/base/lang-url.lua
+++ b/tex/context/base/lang-url.lua
@@ -8,11 +8,11 @@ if not modules then modules = { } end modules ['lang-url'] = {
local utfcharacters, utfvalues, utfbyte, utfchar = utf.characters, utf.values, utf.byte, utf.char
+context = context
+
commands = commands or { }
local commands = commands
-context = context
-
--[[
Hyphenating 's is somewhat tricky and a matter of taste. I did
consider using a dedicated hyphenation pattern or dealing with it by node
diff --git a/tex/context/base/lang-wrd.lua b/tex/context/base/lang-wrd.lua
index bf066fc09..06a2311a6 100644
--- a/tex/context/base/lang-wrd.lua
+++ b/tex/context/base/lang-wrd.lua
@@ -334,17 +334,17 @@ end
-- for the moment we hook it into the attribute handler
--- languagehacks = { }
+--~ languagehacks = { }
--- function languagehacks.process(namespace,attribute,head)
--- return languages.check(head)
--- end
+--~ function languagehacks.process(namespace,attribute,head)
+--~ return languages.check(head)
+--~ end
--- chars.plugins[chars.plugins+1] = {
--- name = "language",
--- namespace = languagehacks,
--- processor = languagehacks.process
--- }
+--~ chars.plugins[chars.plugins+1] = {
+--~ name = "language",
+--~ namespace = languagehacks,
+--~ processor = languagehacks.process
+--~ }
-- interface
diff --git a/tex/context/base/layo-ini.lua b/tex/context/base/layo-ini.lua
index d35d7ef69..56ced2c0b 100644
--- a/tex/context/base/layo-ini.lua
+++ b/tex/context/base/layo-ini.lua
@@ -6,10 +6,17 @@ if not modules then modules = { } end modules ['layo-ini'] = {
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.
+-- We need to share information between the TeX and Lua end
+-- about the typographical model. This happens here.
+--
+-- Code might move.
-local texgetcount = tex.getcount
+-- conditionals.layoutisdoublesided
+-- conditionals.layoutissinglesided
+-- texcount.pagenoshift
+-- texcount.realpageno
+
+local texcount = tex.count
local conditionals = tex.conditionals
layouts = {
@@ -26,14 +33,14 @@ function status.leftorrightpagection(left,right)
return left, right
elseif conditionals.layoutissinglesided then
return left, right
- elseif texgetcount("pagenoshift") % 2 == 0 then
- if texgetcount("realpageno") % 2 == 0 then
+ elseif texcount.pagenoshift % 2 == 0 then
+ if texcount.realpageno % 2 == 0 then
return right, left
else
return left, right
end
else
- if texgetcount("realpageno") % 2 == 0 then
+ if texcount.realpageno % 2 == 0 then
return left, right
else
return right, left
@@ -46,9 +53,9 @@ function status.isleftpage()
return false
elseif conditionals.layoutissinglesided then
return false
- elseif texgetcount("pagenoshift") % 2 == 0 then
- return texgetcount("realpageno") % 2 == 0
+ elseif texcount.pagenoshift % 2 == 0 then
+ return texcount.realpageno % 2 == 0
else
- return not texgetcount("realpageno") % 2 == 0
+ return not texcount.realpageno % 2 == 0
end
end
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index 3f0e718b3..adfea3812 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -12,6 +12,7 @@ if not modules then modules = { } end modules ['lpdf-ano'] = {
local next, tostring = next, tostring
local rep, format = string.rep, string.format
+local texcount = tex.count
local lpegmatch = lpeg.match
local formatters = string.formatters
@@ -51,8 +52,6 @@ local pdfannotation_node = nodepool.pdfannotation
local pdfdestination_node = nodepool.pdfdestination
local latelua_node = nodepool.latelua
-local texgetcount = tex.getcount
-
local pdfdictionary = lpdf.dictionary
local pdfarray = lpdf.array
local pdfreference = lpdf.reference
@@ -335,38 +334,13 @@ end
-- runners and specials
--- runners["inner"] = function(var,actions)
--- if getinnermethod() == "names" then
--- local vi = var.i
--- if vi then
--- local vir = vi.references
--- if vir then
--- local internal = vir.internal
--- if internal then
--- var.inner = "aut:" .. internal
--- end
--- end
--- end
--- else
--- var.inner = nil
--- end
--- local prefix = var.p
--- local inner = var.inner
--- if inner and prefix and prefix ~= "" then
--- inner = prefix .. ":" .. inner -- might not always be ok
--- end
--- return link(nil,nil,inner,var.r,actions)
--- end
-
runners["inner"] = function(var,actions)
- local internal = false
if getinnermethod() == "names" then
local vi = var.i
if vi then
local vir = vi.references
if vir then
- -- todo: no need for it when we have a real reference
- internal = vir.internal
+ local internal = vir.internal
if internal then
var.inner = "aut:" .. internal
end
@@ -377,9 +351,8 @@ runners["inner"] = function(var,actions)
end
local prefix = var.p
local inner = var.inner
- if not internal and inner and prefix and prefix ~= "" then
- -- no prefix with e.g. components
- inner = prefix .. ":" .. inner
+ if inner and prefix and prefix ~= "" then
+ inner = prefix .. ":" .. inner -- might not always be ok
end
return link(nil,nil,inner,var.r,actions)
end
@@ -513,7 +486,7 @@ end
function specials.deltapage(var,actions)
local p = tonumber(var.operation)
if p then
- p = references.checkedrealpage(p + texgetcount("realpageno"))
+ p = references.checkedrealpage(p + texcount.realpageno)
return link(nil,nil,nil,p,actions)
end
end
diff --git a/tex/context/base/lpdf-epa.lua b/tex/context/base/lpdf-epa.lua
index 61d57b8d3..034e6d7e2 100644
--- a/tex/context/base/lpdf-epa.lua
+++ b/tex/context/base/lpdf-epa.lua
@@ -15,12 +15,11 @@ local formatters = string.formatters
----- lpegmatch, lpegpatterns = lpeg.match, lpeg.patterns
-local trace_links = false trackers.register("figures.links", function(v) trace_links = v end)
-local report_link = logs.reporter("backend","merging")
+local trace_links = false trackers.register("figures.links", function(v) trace_links = v end)
-local backends = backends
-local lpdf = lpdf
-local context = context
+local report_link = logs.reporter("backend","merging")
+
+local backends, lpdf = backends, lpdf
local variables = interfaces.variables
local codeinjections = backends.pdf.codeinjections
diff --git a/tex/context/base/lpdf-fmt.lua b/tex/context/base/lpdf-fmt.lua
index b444f03c3..94c005f65 100644
--- a/tex/context/base/lpdf-fmt.lua
+++ b/tex/context/base/lpdf-fmt.lua
@@ -36,7 +36,7 @@ local pdfstring = lpdf.string
local pdfverbose = lpdf.verbose
local pdfflushstreamfileobject = lpdf.flushstreamfileobject
-local texset = tex.set
+local texset = tex.set -- we could make tex.setglobal
local addtoinfo = lpdf.addtoinfo
local injectxmpinfo = lpdf.injectxmpinfo
diff --git a/tex/context/base/lpdf-nod.lua b/tex/context/base/lpdf-nod.lua
index 6b104d2fa..60d3fcd5b 100644
--- a/tex/context/base/lpdf-nod.lua
+++ b/tex/context/base/lpdf-nod.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['lpdf-nod'] = {
license = "see context related readme files"
}
-local formatters = string.formatters
+local format = string.format
local copy_node = node.copy
local new_node = node.new
@@ -59,41 +59,7 @@ end
function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty)
local t = copy_node(pdfsetmatrix)
- t.data = formatters["%s %s %s %s"](rx or 0,sx or 0,sy or 0,ry or 0) -- todo: tx ty
- return t
-end
-
-function nodepool.pdfsetmatrix(rx,sx,sy,ry,tx,ty)
- local t = copy_node(pdfsetmatrix)
- if type(rx) == "string" then
- t.data = rx
- else
- 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
- t.data = "1 0 0 1"
- else
- t.data = formatters["%0.6f 0 0 %0.6f"](rx,ry)
- end
- else
- t.data = formatters["%0.6f %0.6f %0.6f %0.6f"](rx,sx,sy,ry)
- end
- end
+ t.data = format("%s %s %s %s",rx or 0,sx or 0,sy or 0,ry or 0) -- todo: tx ty
return t
end
@@ -161,12 +127,8 @@ function nodepool.pdfdestination(w,h,d,name,view,n)
local m = copy_node(pdfsetmatrix)
local r = copy_node(pdfrestore)
m.data = "1 0 0 1"
- s.next = m
- m.next = t
- t.next = r
- m.prev = s
- t.prev = m
- r.prev = t
+ s.next = m m.next = t t.next = r
+ m.prev = s t.prev = m r.prev = t
return s -- a list
else
return t
diff --git a/tex/context/base/lpdf-tag.lua b/tex/context/base/lpdf-tag.lua
index 29ffcd207..8cdb5f6a4 100644
--- a/tex/context/base/lpdf-tag.lua
+++ b/tex/context/base/lpdf-tag.lua
@@ -32,8 +32,6 @@ local pdfflushobject = lpdf.flushobject
local pdfreserveobject = lpdf.reserveobject
local pdfpagereference = lpdf.pagereference
-local texgetcount = tex.getcount
-
local nodepool = nodes.pool
local pdfliteral = nodepool.pdfliteral
@@ -71,9 +69,10 @@ local dashsplitter = lpeg.splitat("-")
local add_ids = false -- true
--- function codeinjections.maptag(original,target,kind)
--- mapping[original] = { target, kind or "inline" }
--- end
+
+--~ function codeinjections.maptag(original,target,kind)
+--~ mapping[original] = { target, kind or "inline" }
+--~ end
local function finishstructure()
if #structure_kids > 0 then
@@ -134,7 +133,7 @@ local pdf_struct_element = pdfconstant("StructElem")
local function initializepage()
index = 0
- pagenum = texgetcount("realpageno")
+ pagenum = tex.count.realpageno
pageref = pdfreference(pdfpagereference(pagenum))
list = pdfarray()
tree[pagenum] = list -- we can flush after done, todo
diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua
index 30bd3572b..9ea4744f1 100644
--- a/tex/context/base/lpdf-wid.lua
+++ b/tex/context/base/lpdf-wid.lua
@@ -8,18 +8,14 @@ if not modules then modules = { } end modules ['lpdf-wid'] = {
local gmatch, gsub, find, lower, format = string.gmatch, string.gsub, string.find, string.lower, string.format
local stripstring = string.strip
+local texbox, texcount = tex.box, tex.count
local settings_to_array = utilities.parsers.settings_to_array
local settings_to_hash = utilities.parsers.settings_to_hash
-local report_media = logs.reporter("backend","media")
-local report_attachment = logs.reporter("backend","attachment")
+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 backends, lpdf, nodes = backends, lpdf, nodes
local nodeinjections = backends.pdf.nodeinjections
local codeinjections = backends.pdf.codeinjections
@@ -491,8 +487,8 @@ end
local function insertrenderingwindow(specification)
local label = specification.label
- -- local openpage = specification.openpage
- -- local closepage = specification.closepage
+--~ local openpage = specification.openpage
+--~ local closepage = specification.closepage
if specification.option == v_auto then
if openpageaction then
-- \handlereferenceactions{\v!StartRendering{#2}}
@@ -508,7 +504,7 @@ local function insertrenderingwindow(specification)
PC = (closepage and lpdf.action(closepage)) or nil,
}
end
- local page = tonumber(specification.page) or texgetcount("realpageno") -- todo
+ local page = tonumber(specification.page) or texcount.realpageno -- todo
local r = mu[label] or pdfreserveannotation() -- why the reserve here?
local a = pdfdictionary {
S = pdfconstant("Rendition"),
@@ -540,34 +536,34 @@ local function insertrendering(specification)
if not mf[label] then
local filename = specification.filename
local isurl = find(filename,"://")
- -- 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 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,
diff --git a/tex/context/base/luat-cbk.lua b/tex/context/base/luat-cbk.lua
index 4f044f9ac..5aa12005b 100644
--- a/tex/context/base/luat-cbk.lua
+++ b/tex/context/base/luat-cbk.lua
@@ -306,7 +306,7 @@ function garbagecollector.check(size,criterium)
end
end
--- this will move to a module
+-- this will move
commands = commands or { }
diff --git a/tex/context/base/luat-env.lua b/tex/context/base/luat-env.lua
index 5558e0303..8753972c6 100644
--- a/tex/context/base/luat-env.lua
+++ b/tex/context/base/luat-env.lua
@@ -20,8 +20,6 @@ local report_lua = logs.reporter("resolvers","lua")
local luautilities = utilities.lua
local luasuffixes = luautilities.suffixes
-local texgettoks = tex and tex.gettoks
-
environment = environment or { }
local environment = environment
@@ -30,7 +28,7 @@ local environment = environment
local mt = {
__index = function(_,k)
if k == "version" then
- local version = texgettoks and texgettoks("contextversiontoks")
+ local version = tex.toks and tex.toks.contextversiontoks
if version and version ~= "" then
rawset(environment,"version",version)
return version
@@ -38,7 +36,7 @@ local mt = {
return "unknown"
end
elseif k == "kind" then
- local kind = texgettoks and texgettoks("contextkindtoks")
+ local kind = tex.toks and tex.toks.contextkindtoks
if kind and kind ~= "" then
rawset(environment,"kind",kind)
return kind
diff --git a/tex/context/base/luat-fio.lua b/tex/context/base/luat-fio.lua
index dcc183167..d61c6f142 100644
--- a/tex/context/base/luat-fio.lua
+++ b/tex/context/base/luat-fio.lua
@@ -84,6 +84,26 @@ if not resolvers.instance then
end
+local report_system = logs.reporter("system","files")
+local report_files = logs.reporter("used files")
+
+luatex.registerstopactions(function()
+ local foundintrees = resolvers.instance.foundintrees
+ if #foundintrees > 0 then
+ logs.pushtarget("logfile")
+ logs.newline()
+ report_system("start used files")
+ logs.newline()
+ for i=1,#foundintrees do
+ report_files("%4i: % T",i,foundintrees[i])
+ end
+ logs.newline()
+ report_system("stop used files")
+ logs.newline()
+ logs.poptarget()
+ 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",
diff --git a/tex/context/base/luat-mac.lua b/tex/context/base/luat-mac.lua
index 282dc8ce3..c8be06b63 100644
--- a/tex/context/base/luat-mac.lua
+++ b/tex/context/base/luat-mac.lua
@@ -76,23 +76,21 @@ local function pop()
top = remove(stack)
end
-local leftbrace = P("{") -- will be in patterns
-local rightbrace = P("}")
-local escape = P("\\")
+local leftbrace = P("{") -- will be in patterns
+local rightbrace = P("}")
+local escape = P("\\")
-local space = patterns.space
-local spaces = space^1
-local newline = patterns.newline
-local nobrace = 1 - leftbrace - rightbrace
+local space = patterns.space
+local spaces = space^1
+local newline = patterns.newline
+local nobrace = 1 - leftbrace - rightbrace
local longleft = leftbrace -- P("(")
local longright = rightbrace -- P(")")
local nolong = 1 - longleft - longright
-local utf8character = P(1) * R("\128\191")^1 -- unchecked but fast
-
-local name = (R("AZ","az") + utf8character)^1
-local csname = (R("AZ","az") + S("@?!_") + utf8character)^1
+local name = R("AZ","az")^1
+local csname = (R("AZ","az") + S("@?!_"))^1
local longname = (longleft/"") * (nolong^1) * (longright/"")
local variable = P("#") * Cs(name + longname)
local escapedname = escape * csname
diff --git a/tex/context/base/lxml-css.lua b/tex/context/base/lxml-css.lua
index 0deaea4d3..c5a85c2bd 100644
--- a/tex/context/base/lxml-css.lua
+++ b/tex/context/base/lxml-css.lua
@@ -30,9 +30,8 @@ if tex then
local exheights = fonts.hashes.exheights
local emwidths = fonts.hashes.emwidths
- local texget = tex.get
- percentage = function(s,pcf) return tonumber(s) * (pcf or texget("hsize")) end
+ percentage = function(s,pcf) return tonumber(s) * (pcf or tex.hsize) end
exheight = function(s,exf) return tonumber(s) * (exf or exheights[true]) end
emwidth = function(s,emf) return tonumber(s) * (emf or emwidths[true]) end
pixels = function(s,pxf) return tonumber(s) * (pxf or emwidths[true]/300) end
@@ -110,17 +109,17 @@ css.padding = padding
-- print(padding("0",pixel,hsize,exheight,emwidth))
--- local currentfont = font.current
--- local texget = tex.get
--- local hashes = fonts.hashes
--- local quads = hashes.quads
--- local xheights = hashes.xheights
+-- local currentfont = font.current
+-- local texdimen = tex.dimen
+-- local hashes = fonts.hashes
+-- local quads = hashes.quads
+-- local xheights = hashes.xheights
--
-- local function padding(str)
-- local font = currentfont()
-- local exheight = xheights[font]
-- local emwidth = quads[font]
--- local hsize = texget("hsize")/100
+-- local hsize = texdimen.hsize/100
-- local pixel = emwidth/100
-- return padding(str,pixel,hsize,exheight,emwidth)
-- end
diff --git a/tex/context/base/lxml-ctx.lua b/tex/context/base/lxml-ctx.lua
index 1191d6796..968dbda71 100644
--- a/tex/context/base/lxml-ctx.lua
+++ b/tex/context/base/lxml-ctx.lua
@@ -10,13 +10,11 @@ if not modules then modules = { } end modules ['lxml-ctx'] = {
local format, find = string.format, string.find
-local xml = xml
+local xml = xml
+
xml.ctx = { }
xml.ctx.enhancers = { }
-local context = context
-local commands = commands
-
-- hashen
function xml.ctx.enhancers.compound(root,lpath,before,tokens,after) -- todo lpeg
diff --git a/tex/context/base/lxml-dir.lua b/tex/context/base/lxml-dir.lua
index 48c0ac41e..3c68664ae 100644
--- a/tex/context/base/lxml-dir.lua
+++ b/tex/context/base/lxml-dir.lua
@@ -24,13 +24,12 @@ local formatters = string.formatters
--
--
-local lxml = lxml
-local context = context
+local lxml, context = lxml, context
-local getid = lxml.getid
+local getid = lxml.getid
-local directives = lxml.directives or { }
-lxml.directives = directives
+lxml.directives = lxml.directives or { }
+local directives = lxml.directives
local report_lxml = logs.reporter("xml","tex")
@@ -107,11 +106,9 @@ directives.handle = handle_setup
function directives.setup(root,attribute,element)
handle_setup('setup',root,attribute,element)
end
-
function directives.before(root,attribute,element)
handle_setup('before',root,attribute,element)
end
-
function directives.after(root,attribute,element)
handle_setup('after',root,attribute,element)
end
diff --git a/tex/context/base/lxml-ini.mkiv b/tex/context/base/lxml-ini.mkiv
index c3ab2dc73..d2d64aa8d 100644
--- a/tex/context/base/lxml-ini.mkiv
+++ b/tex/context/base/lxml-ini.mkiv
@@ -87,10 +87,10 @@
\def\xmldisplayverbatim #1{\ctxlxml{displayverbatim("#1")}}
\def\xmlinlineverbatim #1{\ctxlxml{inlineverbatim("#1")}}
-\def\xmlload #1#2{\ctxlxml{load("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
-\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\directxmlparameter\c!entities","\directxmlparameter\c!compress")}}
+\def\xmlload #1#2{\ctxlxml{load("#1","#2","\p_lxml_entities","\p_lxml_compress")}}
+\def\xmlloadbuffer #1#2{\ctxlxml{loadbuffer("#1","#2","\p_lxml_entities","\p_lxml_compress")}}
+\def\xmlloaddata #1#2{\ctxlxml{loaddata("#1",\!!bs#2\!!es,"\p_lxml_entities","\p_lxml_compress")}}
+\def\xmlloadregistered #1#2{\ctxlxml{loadregistered("#1","\p_lxml_entities","\p_lxml_compress")}}
\def\xmlloaddirectives #1{\ctxlxml{directives.load("any:///#1")}}
\def\xmlpos #1{\ctxlxml{pos("#1")}}
@@ -313,6 +313,17 @@
\xmlprocessingmode\executeifdefined{\??xmldefaults\directxmlparameter\c!default}\plusone
\to \everysetupxml
+\unexpanded\def\initializexmlprocessing % is this still needed?
+ {\the\everysetupxml}
+
+\let\p_lxml_entities\empty
+\let\p_lxml_compress\empty
+
+\appendtoks
+ \edef\p_lxml_entities{\directxmlparameter\c!entities}%
+ \edef\p_lxml_compress{\directxmlparameter\c!compress}%
+\to \everysetupxml
+
\setupxml
[\c!default=, % flush all
\c!compress=\v!no, % strip comment
diff --git a/tex/context/base/lxml-sor.lua b/tex/context/base/lxml-sor.lua
index aba1c3b8d..951017bcd 100644
--- a/tex/context/base/lxml-sor.lua
+++ b/tex/context/base/lxml-sor.lua
@@ -9,12 +9,9 @@ if not modules then modules = { } end modules ['lxml-sor'] = {
local format, concat, rep = string.format, table.concat, string.rep
local lpegmatch = lpeg.match
-local xml = xml
-local lxml = lxml
-local context = context
+local xml, lxml = xml, lxml
-local lxmlsorters = lxml.sorters or { }
-lxml.sorters = lxmlsorters
+lxml.sorters = lxml.sorters or { }
if not lxml.splitid then
local splitter = lpeg.C((1-lpeg.P(":"))^1) * lpeg.P("::") * lpeg.C(lpeg.P(1)^1)
@@ -30,7 +27,7 @@ end
local lists = { }
-function lxmlsorters.reset(name)
+function lxml.sorters.reset(name)
lists[name] = {
sorted = false,
entries = { },
@@ -39,7 +36,7 @@ function lxmlsorters.reset(name)
}
end
-function lxmlsorters.add(name,n,key)
+function lxml.sorters.add(name,n,key)
local list = lists[name]
if list.sorted then
-- reverse is messed up, we could regenerate it and go on
@@ -59,7 +56,7 @@ function lxmlsorters.add(name,n,key)
end
end
-function lxmlsorters.show(name)
+function lxml.sorters.show(name)
local list = lists[name]
local entries = list and list.entries
local NC, NR, bold = context.NC, context.NR, context.bold -- somehow bold is not working
@@ -95,9 +92,9 @@ function lxmlsorters.show(name)
end
end
-lxmlsorters.compare = sorters.comparers.basic -- (a,b)
+lxml.sorters.compare = sorters.comparers.basic -- (a,b)
-function lxmlsorters.sort(name)
+function lxml.sorters.sort(name)
local list = lists[name]
local entries = list and list.entries
if entries then
@@ -120,7 +117,7 @@ function lxmlsorters.sort(name)
r.split = splitter(strip(r.key))
end
-- sorting
- sorters.sort(results,lxmlsorters.compare)
+ sorters.sort(results,lxml.sorters.compare)
-- finalizing
list.nofsorted = #results
local split = { }
@@ -140,7 +137,7 @@ function lxmlsorters.sort(name)
end
end
-function lxmlsorters.flush(name,setup)
+function lxml.sorters.flush(name,setup)
local list = lists[name]
local results = list and list.results
local xmlw = context.xmlw
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua
index 3e10eb96d..2bb5844fc 100644
--- a/tex/context/base/lxml-tab.lua
+++ b/tex/context/base/lxml-tab.lua
@@ -34,8 +34,6 @@ as the current variant was written when showed up and it's easier
build tables in one go.
--ldx]]--
-if lpeg.setmaxstack then lpeg.setmaxstack(1000) end -- deeply nested xml files
-
xml = xml or { }
local xml = xml
@@ -629,6 +627,7 @@ local publicdoctype = doctypename * somespace * P("PUBLIC") * somespace * val
local systemdoctype = doctypename * somespace * P("SYSTEM") * somespace * value * somespace * doctypeset
local simpledoctype = (1-close)^1 -- * balanced^0
local somedoctype = C((somespace * (publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0)
+local somedoctype = C((somespace * (publicdoctype + systemdoctype + definitiondoctype + simpledoctype) * optionalspace)^0)
local instruction = (spacing * begininstruction * someinstruction * endinstruction) / function(...) add_special("@pi@",...) end
local comment = (spacing * begincomment * somecomment * endcomment ) / function(...) add_special("@cm@",...) end
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 09ffa2851..112f62751 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -27,7 +27,6 @@ local catcodenumbers = catcodes.numbers
local ctxcatcodes = catcodenumbers.ctxcatcodes -- todo: use different method
local notcatcodes = catcodenumbers.notcatcodes -- todo: use different method
-local commands = commands
local context = context
local contextsprint = context.sprint -- with catcodes (here we use fast variants, but with option for tracing)
diff --git a/tex/context/base/m-chart.lua b/tex/context/base/m-chart.lua
index 2b9869379..c4da2eb63 100644
--- a/tex/context/base/m-chart.lua
+++ b/tex/context/base/m-chart.lua
@@ -19,7 +19,7 @@ local P, S, C, Cc, lpegmatch = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.match
local report_chart = logs.reporter("chart")
-local points = number.points -- we can use %p instead
+local points = number.points
local variables = interfaces.variables
@@ -499,7 +499,7 @@ local function process_cells(chart,xoffset,yoffset)
local linesettings = settings.line
context("flow_shape_line_color := \\MPcolor{%s} ;", linesettings.color)
context("flow_shape_fill_color := \\MPcolor{%s} ;", linesettings.backgroundcolor)
- context("flow_shape_line_width := %s ; ", points(linesettings.rulethickness))
+ context("flow_shape_line_width := %s ; ", points(linesettingsrulethickness))
elseif focus[cell.focus] or focus[cell.name] then
local focussettings = settings.focus
context("flow_shape_line_color := \\MPcolor{%s} ;", focussettings.framecolor)
@@ -580,7 +580,7 @@ local function process_connections(chart,xoffset,yoffset)
context("flow_touchshape := %s ;", linesettings.offset == v_none and "true" or "false")
context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0)
context("flow_connection_line_color := \\MPcolor{%s} ;",linesettings.color)
- context("flow_connection_line_width := %s ;",points(linesettings.rulethickness))
+ context("flow_connection_line_width := 2pt ;",points(linesettings.rulethickness))
context("flow_connect_%s_%s (%s) (%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,j,cellx,celly,what_cell,otherx,othery,what_other)
context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;")
end
diff --git a/tex/context/base/m-database.lua b/tex/context/base/m-database.lua
index 91e9636ee..47854daa0 100644
--- a/tex/context/base/m-database.lua
+++ b/tex/context/base/m-database.lua
@@ -6,22 +6,20 @@ if not modules then modules = { } end modules ['m-database'] = {
license = "see context related readme files"
}
-local sub, gmatch = string.sub, string.gmatch
+local sub, gmatch, format = string.sub, string.gmatch, string.format
local concat = table.concat
local lpegpatterns, lpegmatch, lpegsplitat = lpeg.patterns, lpeg.match, lpeg.splitat
-local lpegP, lpegC, lpegS, lpegCt, lpegCc, lpegCs = lpeg.P, lpeg.C, lpeg.S, lpeg.Ct, lpeg.Cc, lpeg.Cs
+local lpegP, lpegC, lpegS, lpegCt = lpeg.P, lpeg.C, lpeg.S, lpeg.Ct
local stripstring = string.strip
-moduledata.database = moduledata.database or { }
-moduledata.database.csv = moduledata.database.csv or { }
-
-- One also needs to enable context.trace, here we only plug in some code (maybe
-- some day this tracker will also toggle the main context tracer.
-local trace_flush = false trackers.register("module.database.flush", function(v) trace_flush = v end)
+local trace_flush = false trackers.register("module.database.flush", function(v) trace_flush = v end)
+
local report_database = logs.reporter("database")
-local context = context
+buffers.database = buffers.database or { }
local l_tab = lpegpatterns.tab
local l_space = lpegpatterns.space
@@ -38,7 +36,7 @@ local separators = { -- not interfaced
spaces = l_space^1,
}
-function moduledata.database.csv.process(settings)
+function buffers.database.process(settings)
local data
if settings.type == "file" then
local filename = resolvers.finders.byscheme("any",settings.database)
@@ -48,8 +46,6 @@ function moduledata.database.csv.process(settings)
data = buffers.getlines(settings.database)
end
if data and #data > 0 then
- local catcodes = tonumber(settings.catcodes) or tex.catcodetable
- context.pushcatcodes(catcodes)
if trace_flush then
context.pushlogger(report_database)
end
@@ -59,7 +55,7 @@ function moduledata.database.csv.process(settings)
local left, right = settings.left or "", settings.right or ""
local setups = settings.setups or ""
local strip = settings.strip == v_yes or false
- local command = settings.command or ""
+ local command = settings.command
separatorchar = (not separatorchar and ",") or separators[separatorchar] or separatorchar
local separator = type(separatorchar) == "string" and lpegS(separatorchar) or separatorchar
local whatever = lpegC((1 - separator)^0)
@@ -67,7 +63,7 @@ function moduledata.database.csv.process(settings)
local quotedata = nil
for chr in gmatch(quotechar,".") do
local quotechar = lpegP(chr)
- local quoteword = lpegCs(((l_space^0 * quotechar)/"") * (1 - quotechar)^0 * ((quotechar * l_space^0)/""))
+ local quoteword = l_space^0 * quotechar * lpegC((1 - quotechar)^0) * quotechar * l_space^0
if quotedata then
quotedata = quotedata + quoteword
else
@@ -77,34 +73,12 @@ function moduledata.database.csv.process(settings)
whatever = quotedata + whatever
end
local checker = commentchar ~= "" and lpegS(commentchar)
- if strip then
- whatever = whatever / stripstring
- end
- if left ~= "" then
- whatever = lpegCc(left) * whatever
- end
- if right ~= "" then
- whatever = whatever * lpegCc(right)
- end
- if command ~= "" then
- whatever = lpegCc("{") * whatever * lpegCc("}")
- end
- whatever = whatever * (separator/"" * whatever)^0
- if first ~= "" then
- whatever = lpegCc(first) * whatever
- end
- if last ~= "" then
- whatever = whatever * lpegCc(last)
- end
- if command ~= "" then
- whatever = lpegCs(lpegCc(command) * whatever)
- else
- whatever = lpegCs(whatever)
- end
+ local splitter = lpegCt(whatever * (separator * whatever)^0)
local found = false
for i=1,#data do
local line = data[i]
if not lpegmatch(l_empty,line) and (not checker or not lpegmatch(checker,line)) then
+ local list = lpegmatch(splitter,line)
if not found then
if setups ~= "" then
context.begingroup()
@@ -113,7 +87,39 @@ function moduledata.database.csv.process(settings)
context(before)
found = true
end
- context(lpegmatch(whatever,line))
+ if trace_flush then
+ local result, r = { }, 0
+ r = r + 1 ; result[r] = first
+ for j=1,#list do
+ local str = strip and stripstring(list[j]) or list[j]
+ r = r + 1 ; result[r] = left
+ if command == "" then
+ r = r + 1 ; result[r] = str
+ else
+ r = r + 1 ; result[r] = command
+ r = r + 1 ; result[r] = "{"
+ r = r + 1 ; result[r] = str
+ r = r + 1 ; result[r] = "}"
+ end
+ r = r + 1 ; result[r] = right
+ end
+ r = r + 1 ; result[r] = last
+ context(concat(result))
+ else
+ context(first)
+ for j=1,#list do
+ local str = strip and stripstring(list[j]) or list[j]
+ context(left)
+ if command == "" then
+ context(str)
+ else
+ context(command)
+ context(false,str)
+ end
+ context(right)
+ end
+ context(last)
+ end
end
end
if found then
@@ -122,7 +128,6 @@ function moduledata.database.csv.process(settings)
context.endgroup()
end
end
- context.popcatcodes()
if trace_flush then
context.poplogger()
end
diff --git a/tex/context/base/m-database.mkiv b/tex/context/base/m-database.mkiv
index cc7dd3d72..0285d3bcd 100644
--- a/tex/context/base/m-database.mkiv
+++ b/tex/context/base/m-database.mkiv
@@ -52,7 +52,7 @@
\let\currentdatabasename\currentdatabase
\let\currentdatabase\empty
\fi
- \ctxlua{moduledata.database.csv.process {
+ \ctxlua{buffers.database.process {
name = "\currentdatabase",
type = "\currentdatabasetype",
database = "\currentdatabasename",
@@ -68,7 +68,6 @@
left = \!!bs\databaseparameter\c!left \!!es,
right = \!!bs\databaseparameter\c!right \!!es,
command = \!!bs\databaseparameter\c!command \!!es,
- catcodes = \number\catcodetable
}}}
\unexpanded\def\processdatabasebuffer{\dodoubleempty\module_database_process_buffer}
@@ -121,7 +120,8 @@
first={\endgraf[},
last={]\endgraf},
left={ (},
- right={) }]
+ right={) },
+ command=\ruledhbox]
\startbuffer[testbuffer]
1,2,3,4,5
diff --git a/tex/context/base/m-graph.mkiv b/tex/context/base/m-graph.mkiv
index e99921c43..c15262cac 100644
--- a/tex/context/base/m-graph.mkiv
+++ b/tex/context/base/m-graph.mkiv
@@ -64,7 +64,14 @@
\c!method=\s!double]
\startMPdefinitions{graph}
- if unknown context_grap : input mp-grap.mpiv ; fi ;
+ if unknown context_grap: input "mp-grap.mpiv" ; fi ;
+\stopMPdefinitions
+
+% For backwards compatibility (for the moment), also load the graph macros in
+% the standard MP instance (scaled integer):
+
+\startMPdefinitions
+ if unknown context_grap: input "mp-grap.mpiv" ; fi ;
\stopMPdefinitions
\protect
diff --git a/tex/context/base/m-hemistich.mkiv b/tex/context/base/m-hemistich.mkiv
deleted file mode 100644
index 55fde7b92..000000000
--- a/tex/context/base/m-hemistich.mkiv
+++ /dev/null
@@ -1,112 +0,0 @@
-%D \module
-%D [ file=m-hemistich,
-%D version=2013.08.26,
-%D title=\CONTEXT\ Extra Modules,
-%D subtitle=Hemistiches,
-%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 module for Idris. More is possible but not now.
-
-\unprotect
-
-\installcorenamespace{hemistich}
-
-\installcommandhandler \??hemistich {hemistich} \??hemistich
-
-\setuphemistich
- [\c!width=\v!local,
- \c!distance=4\emwidth,
- \c!separator=\vl\hskip.25em\vl]
-
-\unexpanded\def\hemistiches
- {\dosingleempty\dohemistiches}
-
-\unexpanded\def\dohemistiches
- {\dodohemistiches\empty}
-
-\unexpanded\def\dodohemistiches#1[#2]#3#4%
- {\dontleavehmode
- \begingroup
- \doifassignmentelse{#2}
- {\edef\currenthemistich{#1}%
- \setupcurrenthemistich[#2]}
- {\def\currenthemistich{#2}}%
- \doifelse{\hemistichparameter\c!width}\v!local
- {\scratchwidth\availablehsize}
- {\scratchwidth\hemistichparameter\c!width\relax}%
- \spaceskip\zeropoint\s!plus\plusone\s!fill\relax
- \hbox to \scratchwidth\bgroup
- \scratchwidth.5\dimexpr\scratchwidth-\hemistichparameter\c!distance\relax
- \hbox to \scratchwidth\bgroup
- \usehemistichstyleandcolor\c!leftstyle\c!leftcolor#3%
- \egroup
- \hss
- \begingroup
- \usehemistichstyleandcolor\c!separatorstyle\c!separatorcolor
- \hemistichparameter\c!separator
- \endgroup
- \hss
- \hbox to \scratchwidth\bgroup
- \usehemistichstyleandcolor\c!rightstyle\c!rightcolor#4%
- \egroup
- \egroup
- \endgroup}
-
-\unexpanded\def\hemistichescaesura#1#2#3%
- {\dodohemistiches\empty[\c!separator={#2}]{#1}{#3}}
-
-\appendtoks
- \setvalue{\currenthemistich}{\dohemistiches{\currenthemistich}}%
-\to \everydefinehemistich
-
-\protect
-
-\continueifinputfile{m-hemistich.mkiv}
-
-\setuphemistich
- [leftcolor=darkred,
- separatorcolor=darkgreen,
- rightcolor=darkblue]
-
-\setupwhitespace
- [big]
-
-\starttext
-
-% \righttoleft
-
-\hemistichescaesura{left side of the brain}{equals}{right side of the brain}
-
-\hemistiches{left side of the brain}{right side of the brain}
-
-\startitemize
- \startitem
- \hemistiches{left side of the brain}{right side of the brain}
- \startitemize
- \startitem
- \hemistiches{left side of the brain}{right side of the brain}
- \startitemize
- \startitem
- \hemistiches{left side of the brain}{right side of the brain}
- \stopitem
- \stopitemize
- \stopitem
- \stopitemize
- \startitem
- \hemistiches{left side of the brain}{right side of the brain}
- \stopitem
- \stopitem
-\stopitemize
-
-\startitemize
-\item \hemistiches{left side of the brain}{right side of the brain}
-\stopitemize
-
-\stoptext
-
diff --git a/tex/context/base/m-nodechart.lua b/tex/context/base/m-nodechart.lua
deleted file mode 100644
index 612b73767..000000000
--- a/tex/context/base/m-nodechart.lua
+++ /dev/null
@@ -1,175 +0,0 @@
-if not modules then modules = { } end modules ['m-nodechart'] = {
- version = 1.001,
- comment = "companion to m-nodechart.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 points = number.nopts
-local ptfactor = number.dimenfactors.pt
-
-local nodecodes = nodes.nodecodes
-local kerncodes = nodes.kerncodes
-local penaltycodes = nodes.penaltycodes
-local gluecodes = nodes.gluecodes
-local whatsitcodes = nodes.whatsitcodes
-
-moduledata.charts = moduledata.charts or { }
-moduledata.charts.nodes = moduledata.charts.nodes or { }
-
-local formatters = { }
-
--- subtype font char lang left right uchyph components xoffset yoffset width height depth
-
-function formatters.glyph(n,comment)
- return format("\\doFLOWglyphnode{%s}{%s}{%s}{%s}{U+%05X}",comment,n.subtype,n.font,n.char,n.char)
-end
-
--- pre post replace
-
-function formatters.disc(n,comment)
- return format("\\doFLOWdiscnode{%s}{%s}",comment,n.subtype)
-end
-
--- subtype kern
-
-function formatters.kern(n,comment)
- -- return format("\\doFLOWkernnode{%s}{%s}{%s}",comment,kerncodes[n.subtype],points(n.kern))
- return format("\\doFLOWkernnode{%s}{%s}{%.4f}",comment,kerncodes[n.subtype],n.kern*ptfactor)
-end
-
--- subtype penalty
-
-function formatters.penalty(n,comment)
- return format("\\doFLOWpenaltynode{%s}{%s}{%s}",comment,"penalty",n.penalty)
-end
-
--- subtype width leader spec (stretch shrink ...
-
-function formatters.glue(n,comment)
- local s = n.spec
- -- return format("\\doFLOWgluenode{%s}{%s}{%s}{%s}{%s}",comment,gluecodes[n.subtype],points(s.width),points(s.stretch),points(s.shrink))
- return format("\\doFLOWgluenode{%s}{%s}{%.4f}{%.4f}{%.4f}",comment,gluecodes[n.subtype],s.width*ptfactor,s.stretch*ptfactor,s.shrink*ptfactor)
-end
-
--- subtype width leader spec (stretch shrink ...
-
-function formatters.whatsit(n,comment)
- local subtype = n.subtype
- local whatsit = whatsitcodes[subtype]
- if whatsit == "dir" or whatsit == "localpar" then
- return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,whatsit,n.dir)
- else
- return nodecodes[n.id]
- end
-end
-
--- I will make a dedicated set of shapes for this.
-
-local shapes = {
- glyph = "procedure",
- disc = "procedure",
- kern = "action",
- penalty = "action",
- glue = "action",
-}
-
-local function flow_nodes_to_chart(specification)
- local head = specification.head
- local box = specification.box
- local comment = specification.comment or ""
- local x = specification.x or 1
- local y = specification.y or 0
- --
- if box then
- box = tex.getbox(tonumber(box))
- head = box and box.list
- end
- --
- local current = head
- --
- while current do
- local nodecode = nodecodes[current.id]
- local formatter = formatters[nodecode]
- local shape = shapes[nodecode]
- y = y + 1
- local next = current.next
- commands.flow_start_cell { shape = { framecolor = "nodechart:" .. nodecode } }
- commands.flow_set_name(tostring(current))
- commands.flow_set_location(x,y)
- if shape then
- commands.flow_set_shape(shape)
- end
- if formatter then
- commands.flow_set_text("node",formatter(current,comment))
- else
- commands.flow_set_text("node",nodecode)
- end
- if next then
- commands.flow_set_connection("bt","",tostring(next))
- end
- if nodecode == "glyph" then
- local components = current.components
- if components then
- commands.flow_set_connection("rl","",tostring(components))
- commands.flow_stop_cell()
- n = flow_nodes_to_chart { head = components, comment = "component",x = x+2, y = y-1 }
- else
- commands.flow_stop_cell()
- end
- elseif nodecode == "disc" then
- local pre = current.pre
- local pos = current.post
- local rep = current.replace
- if pre and not rep and not rep then
- if pre then
- commands.flow_set_connection("rl","",tostring(pre))
- end
- commands.flow_stop_cell()
- if pre then
- n = flow_nodes_to_chart { head = pre, comment = "prebreak", x = x+1, y = y-1 }
- end
- else
- if pre then
- commands.flow_set_connection("+rl","",tostring(pre))
- end
- if rep then
- commands.flow_set_connection("rl","",tostring(rep))
- end
- if pos then
- commands.flow_set_connection("-rl","",tostring(pos))
- end
- commands.flow_stop_cell()
- if pre then
- n = flow_nodes_to_chart{ head = pre, comment = "prebreak", x = x+1, y = y-2 }
- end
- if rep then
- n = flow_nodes_to_chart{ head = rep, comment = "replacement", x = x+1, y = y-1 }
- end
- if pos then
- n = flow_nodes_to_chart{ head = pos, comment = "postbreak", x = x+1, y = y }
- end
- end
- elseif nodecode == "hlist" then
- local list = current.list
- if list then
- commands.flow_set_connection("rl","",tostring(list))
- commands.flow_stop_cell()
- n = flow_nodes_to_chart { head = list, comment = "list", x = x+2, y = y-1 }
- else
- commands.flow_stop_cell()
- end
- else
- commands.flow_stop_cell()
- end
- current = next
- end
-end
-
-function moduledata.charts.nodes.chart(specification)
- commands.flow_start_chart(specification.name)
- flow_nodes_to_chart(specification)
- commands.flow_stop_chart()
-end
diff --git a/tex/context/base/m-nodechart.mkvi b/tex/context/base/m-nodechart.mkvi
index c9d985850..359d598ce 100644
--- a/tex/context/base/m-nodechart.mkvi
+++ b/tex/context/base/m-nodechart.mkvi
@@ -1,20 +1,155 @@
-%D \module
-%D [ file=m-nodechart,
-%D version=2011.11.11, % nos sure when it started, needed for fonts-mkiv
-%D title=\CONTEXT\ Modules,
-%D subtitle=Node Visualization,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-\registerctxluafile{m-nodechart}{1.001}
-
\usemodule[chart]
+\startluacode
+
+local format = string.format
+local points = number.nopts
+local ptfactor = number.dimenfactors.pt
+
+local nodecodes = nodes.nodecodes
+local kerncodes = nodes.kerncodes
+local penaltycodes = nodes.penaltycodes
+local gluecodes = nodes.gluecodes
+local whatsitcodes = nodes.whatsitcodes
+
+local formatters = { }
+
+function formatters.glyph(n,comment)
+ -- subtype font char lang left right uchyph components xoffset yoffset width height depth
+ return format("\\doFLOWglyphnode{%s}{%s}{%s}{%s}{U+%05X}",comment,n.subtype,n.font,n.char,n.char)
+end
+
+function formatters.disc(n,comment)
+ -- pre post replace
+ return format("\\doFLOWdiscnode{%s}{%s}",comment,n.subtype)
+end
+
+function formatters.kern(n,comment)
+ -- subtype kern
+ -- return format("\\doFLOWkernnode{%s}{%s}{%s}",comment,kerncodes[n.subtype],points(n.kern))
+ return format("\\doFLOWkernnode{%s}{%s}{%.4f}",comment,kerncodes[n.subtype],n.kern*ptfactor)
+end
+
+function formatters.penalty(n,comment)
+ -- subtype penalty
+ return format("\\doFLOWpenaltynode{%s}{%s}{%s}",comment,"penalty",n.penalty)
+end
+
+function formatters.glue(n,comment)
+ -- subtype width leader spec (stretch shrink ...
+ local s = n.spec
+ -- return format("\\doFLOWgluenode{%s}{%s}{%s}{%s}{%s}",comment,gluecodes[n.subtype],points(s.width),points(s.stretch),points(s.shrink))
+ return format("\\doFLOWgluenode{%s}{%s}{%.4f}{%.4f}{%.4f}",comment,gluecodes[n.subtype],s.width*ptfactor,s.stretch*ptfactor,s.shrink*ptfactor)
+end
+
+function formatters.whatsit(n,comment)
+ -- subtype width leader spec (stretch shrink ...
+ local subtype = n.subtype
+ local whatsit = whatsitcodes[subtype]
+ if whatsit == "dir" or whatsit == "localpar" then
+ return format("\\doFLOWdirnode{%s}{%s}{%s}",comment,whatsit,n.dir)
+ else
+ return nodecodes[n.id]
+ end
+end
+
+local shapes = { -- I will make a dedicated set of shapes for this.
+ glyph = "procedure",
+ disc = "procedure",
+ kern = "action",
+ penalty = "action",
+ glue = "action",
+}
+
+local function flow_nodes_to_chart(head,comment,x,y,how)
+ local current = head
+ while current do
+ local nodecode = nodecodes[current.id]
+ local formatter = formatters[nodecode]
+ local shape = shapes[nodecode]
+ y = y + 1
+ local next = current.next
+ commands.flow_start_cell { shape = { framecolor = "nodechart:" .. nodecode } }
+ commands.flow_set_name(tostring(current))
+ commands.flow_set_location(x,y)
+ if shape then
+ commands.flow_set_shape(shape)
+ end
+ if formatter then
+ commands.flow_set_text("node",formatter(current,comment))
+ else
+ commands.flow_set_text("node",nodecode)
+ end
+ if next then
+ commands.flow_set_connection("bt","",tostring(next))
+ end
+ if nodecode == "glyph" then
+ local components = current.components
+ if components then
+ commands.flow_set_connection("rl","",tostring(components))
+ commands.flow_stop_cell()
+ n = flow_nodes_to_chart(components,"component",x+2,y-1)
+ else
+ commands.flow_stop_cell()
+ end
+ elseif nodecode == "disc" then
+ local pre = current.pre
+ local pos = current.post
+ local rep = current.replace
+ if pre and not rep and not rep then
+ if pre then
+ commands.flow_set_connection("rl","",tostring(pre))
+ end
+ commands.flow_stop_cell()
+ if pre then
+ n = flow_nodes_to_chart(pre,"prebreak",x+1,y-1)
+ end
+ else
+ if pre then
+ commands.flow_set_connection("+rl","",tostring(pre))
+ end
+ if rep then
+ commands.flow_set_connection("rl","",tostring(rep))
+ end
+ if pos then
+ commands.flow_set_connection("-rl","",tostring(pos))
+ end
+ commands.flow_stop_cell()
+ if pre then
+ n = flow_nodes_to_chart(pre,"prebreak",x+1,y-2)
+ end
+ if rep then
+ n = flow_nodes_to_chart(rep,"replacement",x+1,y-1)
+ end
+ if pos then
+ n = flow_nodes_to_chart(pos,"postbreak",x+1,y)
+ end
+ end
+ elseif nodecode == "hlist" then
+ local list = current.list
+ if list then
+ commands.flow_set_connection("rl","",tostring(list))
+ commands.flow_stop_cell()
+ n = flow_nodes_to_chart(list,"list",x+2,y-1)
+ else
+ commands.flow_stop_cell()
+ end
+ else
+ commands.flow_stop_cell()
+ end
+ current = next
+ end
+ return n
+end
+
+function commands.flow_nodes_to_chart(name,head,max)
+ commands.flow_start_chart(name)
+ flow_nodes_to_chart(head,"",1,0)
+ commands.flow_stop_chart()
+end
+
+\stopluacode
+
\unprotect
\def\enspaceminus{\hskip.5em minus .25em\relax}
@@ -65,20 +200,17 @@
% this is a temporary interface ... we will have instances and optional settings
-\unexpanded\def\boxtoFLOWchart[#name]#box%
- {\ctxlua{moduledata.charts.nodes.chart {
- name = "#name",
- box = \number#box,
- }}}
+\unexpanded\def\boxtoFLOWchart#name#max#box%
+ {\ctxcommand{flow_nodes_to_chart("#name",tex.box[\number#box].list,\number#max)}}
-\unexpanded\def\nextboxtoFLOWchart[#name]%
- {\dowithnextbox{\boxtoFLOWchart[#name]\nextbox}}
+\unexpanded\def\nextboxtoFLOWchart#name#max%
+ {\dowithnextbox{\boxtoFLOWchart{#name}{#max}\nextbox}}
-\unexpanded\def\hboxtoFLOWchart[#name]%
- {\nextboxtoFLOWchart[#name]\hbox}
+\unexpanded\def\hboxtoFLOWchart#name#max%
+ {\nextboxtoFLOWchart{#name}{#max}\hbox}
-\unexpanded\def\vboxtoFLOWchart[#name]%
- {\nextboxtoFLOWchart[#name]\vbox}
+\unexpanded\def\vboxtoFLOWchart#name#max%
+ {\nextboxtoFLOWchart{#name}{#max}\vbox}
\protect
@@ -92,7 +224,7 @@
\startTEXpage[offset=10pt]
- \hboxtoFLOWchart[dummy]{an affil\discretionary{-}{-}{!}iation}
+ \hboxtoFLOWchart{dummy}{3}{an affil\discretionary{-}{-}{!}iation}
\FLOWchart[dummy][width=14em,height=3em,dx=1em,dy=.75em,hcompact=yes]
@@ -100,7 +232,7 @@
\startTEXpage[offset=10pt]
- \hboxtoFLOWchart[dummy]{an affiliation}
+ \hboxtoFLOWchart{dummy}{3}{an affiliation}
\FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
@@ -108,7 +240,7 @@
\startTEXpage[offset=10pt]
- \hboxtoFLOWchart[dummy]{\nl effe fijn fietsen}
+ \hboxtoFLOWchart{dummy}{3}{\nl effe fijn fietsen}
\FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
@@ -116,7 +248,7 @@
\startTEXpage[offset=10pt]
- \hboxtoFLOWchart[dummy]{\righttoleft t\kern 1pt est}
+ \hboxtoFLOWchart{dummy}{3}{\righttoleft t\kern 1pt est}
\FLOWchart[dummy][width=14em,height=3em,dx=.5em,dy=.75em,hcompact=yes]
diff --git a/tex/context/base/m-punk.mkiv b/tex/context/base/m-punk.mkiv
index 6bf92e4c0..23b477cb6 100644
--- a/tex/context/base/m-punk.mkiv
+++ b/tex/context/base/m-punk.mkiv
@@ -110,10 +110,7 @@ function metapost.characters.process(mpxformat, name, instances, scalefactor)
data
},
false,
- flusher,
- false,
- false,
- "all"
+ flusher
)
lists[i] = {
characters = characters,
diff --git a/tex/context/base/m-r.mkii b/tex/context/base/m-r.mkii
deleted file mode 100644
index c2cb7ba88..000000000
--- a/tex/context/base/m-r.mkii
+++ /dev/null
@@ -1,174 +0,0 @@
-%D \module
-%D [ file=m-r,
-%D version=2006.06.06,
-%D title=\CONTEXT\ Modules,
-%D subtitle=R Support,
-%D author={Johan Sandblom \& Hans Hagen},
-%D date=\currentdate,
-%D copyright={Johan Sandblom \& Hans Hagen}]
-%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 The following R-processor is a variation on Johan Sandblom's
-%D prototype.
-%D
-%D We can combine both variants in one macro definition. Also, we
-%D can minimize the number of runs by checking for a change.
-
-%D JS: The call to R has \type {-q} in order to prevent banner,
-%D \type {--save} to make sure it saves the workspace after the run,
-%D \type {--restore} to make sure it reads any workspace from a
-%D previous session.
-
-%D An easier and better solution is to use the buffering mechanisms:
-
-\def\Rbufferprefix{r-}
-
-\newcounter\nofRfiles
-
-\def\Rfile{\TEXbufferfile{\Rbufferprefix\nofRfiles}}
-
-\def\startR
- {\doglobal\increment\nofRfiles
- \dostartbuffer[\Rbufferprefix\nofRfiles][startR][stopR]}
-
-\def\stopR
- {\doifmode{*\v!first}\runR
- \typefile{\Rfile.out}}
-
-\def\startRhidden
- {\doglobal\increment\nofRfiles
- \dostartbuffer[\Rbufferprefix\nofRfiles][startRhidden][stopRhidden]}
-
-\def\stopRhidden
- {\doifmode{*\v!first}\runR}
-
-\def\runR
- {\executesystemcommand{texmfstart
- --ifchanged=\Rfile\space --direct R
- CMD BATCH -q --save --restore \Rfile\space \Rfile.out}}
-
-\protect \doifnotmode{demo}{\endinput}
-
-% Johan's test file:
-
-\usemodule[r]
-
-\def\R{R}
-
-\setupcolors[state=start]
-
-\setuptyping
- [Rtype]
- [color=darkgreen]
-
-\starttext
-
-First a test of whether the workspace is persistent:
-bla
-
-\startR
-a <- "bla"
-b <- "blabla"
-ls()
-\stopR
-
-One \R run ends, another begins.
-
-\startR
-ls()
-\stopR
-
-Now follows a hidden \R run which cleans the R workspace
-
-\startRhidden
-rm(list=ls())
-save.image()
-\stopRhidden
-
-What is in the workspace now?
-
-\startR
-ls()
-\stopR
-
-Then a small test of generating a graphic, in this case a pdf
-\startR
-ushape <- c(rexp(500000), 12-rexp(500000))
-pdf("ushape.pdf")
-par(mfrow=c(1,2))
-hist(ushape)
-plot(density(ushape), main="Density")
-dev.off()
-\stopR
-
-The graphic \type{ushape.pdf} can be included in the standard \CONTEXT\ way
-\startbuffer
-\placefigure{An ugly distribution}{\externalfigure[ushape]}
-\stopbuffer
-\typebuffer
-\getbuffer
-
-\startR
-x <- rnorm(900)
-y <- rexp(900)
-# test comment
-f <- gl(9,9,900)
-summary(aov(y~x+Error(f)))
-library(lattice)
-pdf("lattice.pdf")
-xyplot(y~x|f)
-dev.off()
-\stopR
-
-With \type{Sweave} lattice graphics calls must be enclosed in
-\type{print()} statements but that is not necessary here.
-
-\startbuffer
-\placefigure[here]{Lattice graphics}{\externalfigure[lattice]}
-\stopbuffer
-\typebuffer
-\getbuffer
-
-A test string with nasty characters. In \R, the result of a statement
-is not printed by default. Enclosing the statement in parentheses,
-however causes the parser to see only the value of the statement and
-applying the \type{print()} method.
-\startR
-(test <- ".*\\\\ [[{[{]{[{[{}\]\}=?!+%#|<|>@$")
-cat(test)
-\stopR
-
-A combination
-\startbuffer
-\placefigure{A combination of two previously used graphics}{
-\startcombination[2*1]
- {\externalfigure[ushape][width=.4\textwidth]}{The first graphic, rescaled}
- {\externalfigure[lattice][width=.4\textwidth]}{The second graphic, rescaled}}
-\stopcombination
-\stopbuffer
-\typebuffer
-\getbuffer
-
-Testing a function definition.
-
-\startR
-a.df <- data.frame(a=1:2, b=rnorm(2))
-a.df$a
-testfunction <- function(a=NULL, ...) {
- for(i in 1:length(a)) {
- gsub(a[[i]], "([a-r]|[A-R])", "bla")}
- print(a)}
-\stopR
-
-What is in the workspace now?
-
-\startR
-ls()
-\stopR
-
-\stoptext
diff --git a/tex/context/base/m-r.tex b/tex/context/base/m-r.tex
new file mode 100644
index 000000000..ac895905c
--- /dev/null
+++ b/tex/context/base/m-r.tex
@@ -0,0 +1,174 @@
+%D \module
+%D [ file=m-r,
+%D version=2006.06.06,
+%D title=\CONTEXT\ Modules,
+%D subtitle=R Support,
+%D author={Johan Sandblom \& Hans Hagen},
+%D date=\currentdate,
+%D copyright={Johan Sandblom \& Hans Hagen}]
+%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 The following R-processor is a variation on Johan Sandblom's
+%D prototype.
+%D
+%D We can combine both variants in one macro definition. Also, we
+%D can minimize the number of runs by checking for a change.
+
+%D JS: The call to R has \type {-q} in order to prevent banner,
+%D \type {--save} to make sure it saves the workspace after the run,
+%D \type {--restore} to make sure it reads any workspace from a
+%D previous session.
+
+%D An easier and better solution is to use the buffering mechanisms:
+
+\def\Rbufferprefix{r-}
+
+\newcounter\nofRfiles
+
+\def\Rfile{\TEXbufferfile{\Rbufferprefix\nofRfiles}}%
+
+\def\startR
+ {\doglobal\increment\nofRfiles
+ \dostartbuffer[\Rbufferprefix\nofRfiles][startR][stopR]}
+
+\def\stopR
+ {\doifmode{*\v!first}\runR
+ \typefile{\Rfile.out}}
+
+\def\startRhidden
+ {\doglobal\increment\nofRfiles
+ \dostartbuffer[\Rbufferprefix\nofRfiles][startRhidden][stopRhidden]}
+
+\def\stopRhidden
+ {\doifmode{*\v!first}\runR}
+
+\def\runR
+ {\executesystemcommand{texmfstart
+ --ifchanged=\Rfile\space --direct R
+ CMD BATCH -q --save --restore \Rfile\space \Rfile.out}}
+
+\protect \doifnotmode{demo}{\endinput}
+
+% Johan's test file:
+
+\usemodule[r]
+
+\def\R{R}
+
+\setupcolors[state=start]
+
+\setuptyping
+ [Rtype]
+ [color=darkgreen]
+
+\starttext
+
+First a test of whether the workspace is persistent:
+bla
+
+\startR
+a <- "bla"
+b <- "blabla"
+ls()
+\stopR
+
+One \R run ends, another begins.
+
+\startR
+ls()
+\stopR
+
+Now follows a hidden \R run which cleans the R workspace
+
+\startRhidden
+rm(list=ls())
+save.image()
+\stopRhidden
+
+What is in the workspace now?
+
+\startR
+ls()
+\stopR
+
+Then a small test of generating a graphic, in this case a pdf
+\startR
+ushape <- c(rexp(500000), 12-rexp(500000))
+pdf("ushape.pdf")
+par(mfrow=c(1,2))
+hist(ushape)
+plot(density(ushape), main="Density")
+dev.off()
+\stopR
+
+The graphic \type{ushape.pdf} can be included in the standard \CONTEXT\ way
+\startbuffer
+\placefigure{An ugly distribution}{\externalfigure[ushape]}
+\stopbuffer
+\typebuffer
+\getbuffer
+
+\startR
+x <- rnorm(900)
+y <- rexp(900)
+# test comment
+f <- gl(9,9,900)
+summary(aov(y~x+Error(f)))
+library(lattice)
+pdf("lattice.pdf")
+xyplot(y~x|f)
+dev.off()
+\stopR
+
+With \type{Sweave} lattice graphics calls must be enclosed in
+\type{print()} statements but that is not necessary here.
+
+\startbuffer
+\placefigure[here]{Lattice graphics}{\externalfigure[lattice]}
+\stopbuffer
+\typebuffer
+\getbuffer
+
+A test string with nasty characters. In \R, the result of a statement
+is not printed by default. Enclosing the statement in parentheses,
+however causes the parser to see only the value of the statement and
+applying the \type{print()} method.
+\startR
+(test <- ".*\\\\ [[{[{]{[{[{}\]\}=?!+%#|<|>@$")
+cat(test)
+\stopR
+
+A combination
+\startbuffer
+\placefigure{A combination of two previously used graphics}{
+\startcombination[2*1]
+ {\externalfigure[ushape][width=.4\textwidth]}{The first graphic, rescaled}
+ {\externalfigure[lattice][width=.4\textwidth]}{The second graphic, rescaled}}
+\stopcombination
+\stopbuffer
+\typebuffer
+\getbuffer
+
+Testing a function definition.
+
+\startR
+a.df <- data.frame(a=1:2, b=rnorm(2))
+a.df$a
+testfunction <- function(a=NULL, ...) {
+ for(i in 1:length(a)) {
+ gsub(a[[i]], "([a-r]|[A-R])", "bla")}
+ print(a)}
+\stopR
+
+What is in the workspace now?
+
+\startR
+ls()
+\stopR
+
+\stoptext
diff --git a/tex/context/base/m-spreadsheet.lua b/tex/context/base/m-spreadsheet.lua
index f329acf9a..9d5106e35 100644
--- a/tex/context/base/m-spreadsheet.lua
+++ b/tex/context/base/m-spreadsheet.lua
@@ -172,7 +172,7 @@ function functions._s_(row,col,c,f,t)
for i=f,t do
local ci = c[i]
if type(ci) == "number" then
- r = r + ci
+ r = r + c[i]
end
end
return r
diff --git a/tex/context/base/m-spreadsheet.mkiv b/tex/context/base/m-spreadsheet.mkiv
index 5e0499184..a05968990 100644
--- a/tex/context/base/m-spreadsheet.mkiv
+++ b/tex/context/base/m-spreadsheet.mkiv
@@ -120,15 +120,12 @@
\let\stopcell \module_spreadsheet_cell_stop
\doifassignmentelse{#1}
{\module_spreadsheet_start
- \directsetup{spreadsheet:before:\currentspreadsheet}%
\bTABLE[\c!align=\v!flushright,#1]}
{\module_spreadsheet_start[#1]%
- \directsetup{spreadsheet:before:\currentspreadsheet}%
\bTABLE[\c!align=\v!flushright,#2]}}
\unexpanded\def\stopspreadsheettable
{\eTABLE
- \directsetup{spreadsheet:after:\currentspreadsheet}%
\stopspreadsheet
\egroup}
diff --git a/tex/context/base/m-translate.mkiv b/tex/context/base/m-translate.mkiv
index f36f9a9fb..363f115cb 100644
--- a/tex/context/base/m-translate.mkiv
+++ b/tex/context/base/m-translate.mkiv
@@ -89,6 +89,7 @@
\continueifinputfile{m-translate.mkiv}
+
\starttext
\translateinput[Moica][Mojca]
diff --git a/tex/context/base/m-zint.mkiv b/tex/context/base/m-zint.mkiv
index 4957c8461..95b265c57 100644
--- a/tex/context/base/m-zint.mkiv
+++ b/tex/context/base/m-zint.mkiv
@@ -29,21 +29,17 @@ moduledata.zint = { }
local format, lower, gsub = string.format, string.lower, string.gsub
local patterns = lpeg.patterns
-local zint = "zint" -- '"c:/program files/zint/zint.exe"'
-local defaultcode = "PDF417"
+local zint = "zint" -- '"c:/program files/zint/zint.exe"'
-local whitespace = patterns.whitespace
-local spaces = whitespace^0
-local key = (spaces / "") * patterns.digit^0 * (patterns.colon * spaces / "")
-local value = (whitespace / "" + (1 - key))^1
-local pattern = lpeg.Cf(lpeg.Ct("") * (lpeg.Cg((lpeg.Cs(key) / tonumber) * (lpeg.Cs(value) / lower)) + patterns.anything)^0,rawset)
+local whitespace = patterns.whitespace
+local spaces = whitespace^0
+local key = (spaces / "") * patterns.digit^0 * (patterns.colon * spaces / "")
+local value = (whitespace / "" + (1 - key))^1
+local pattern = lpeg.Cf(lpeg.Ct("") * (lpeg.Cg((lpeg.Cs(key) / tonumber) * (lpeg.Cs(value) / lower)) + patterns.anything)^0,rawset)
local reverse
local function cleancode(code)
- if not code or code == "" then
- code = defaultcode
- end
return lower(gsub(code," ",""))
end
@@ -80,19 +76,6 @@ end
\stopluacode
-\unprotect
-
-\unexpanded\def\barcode[#1]% [alternative=,text=]
- {\bgroup
- \getdummyparameters
- [\c!alternative=,\c!text=,#1]%
- \externalfigure
- [\cldcontext{moduledata.zint.generate("\dummyparameter\c!alternative",\!!bs\dummyparameter\c!text\!!es)}]%
- [#1,\c!alternative=,\c!text=]%
- \egroup}
-
-\protect
-
\continueifinputfile{m-zint.mkiv}
\starttext
@@ -102,10 +85,6 @@ end
\externalfigure[\cldcontext{moduledata.zint.generate("PDF417","Ton Otten")}]
\blank
\externalfigure[\cldcontext{moduledata.zint.generate("ISBN","9789490688011")}]
- \blank
- \barcode[text=Does It Work?,width=\textwidth]
- \blank
- \barcode[alternative=isbn,text=9789490688011,width=3cm]
\stoptext
diff --git a/tex/context/base/math-acc.mkvi b/tex/context/base/math-acc.mkvi
deleted file mode 100644
index 415f2b91f..000000000
--- a/tex/context/base/math-acc.mkvi
+++ /dev/null
@@ -1,181 +0,0 @@
-%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} $
-
-% A first variant (kept for educational purposed):
-%
-% \installcorenamespace{mathaccents}
-%
-% \installcommandhandler \??mathaccents {mathaccent} \??mathaccents
-%
-% \let\setupmathaccents\setupmathaccent
-%
-% \setupmathaccents
-% [\c!top=,
-% \c!bottom=,
-% \c!mathstyle=,
-% \c!color=,
-% \c!command=\v!yes]
-%
-% \appendtoks
-% \edef\p_top_bottom{\namedmathaccentparameter\currentmathaccent\c!top\namedmathaccentparameter\currentmathaccent\c!bottom}%
-% \ifx\p_top_bottom\empty\else
-% \edef\p_command{\mathaccentparameter\c!command}%
-% \ifx\p_command\v!yes
-% \setuevalue\currentmathaccent{\math_accent{\currentmathaccent}}%
-% \fi
-% \fi
-% \to \everydefinemathaccent
-%
-% \def\math_accented_color_do_push{\pushcolor[\p_math_accent_color]}
-% \let\math_accented_color_do_pop \popcolor
-%
-% \unexpanded\def\math_accent#1#2%
-% {\begingroup
-% \edef\currentmathaccent{#1}%
-% \edef\p_math_accent_top {\mathaccentparameter\c!top}%
-% \edef\p_math_accent_bottom{\mathaccentparameter\c!bottom}%
-% \edef\p_math_accent_color {\mathaccentparameter\c!color}%
-% \startusemathstyleparameter\mathaccentparameter
-% \ifx\p_math_accented_color\empty
-% \let\math_accented_color_do_pop\donothing
-% \else
-% \let\math_accented_color_do_pop\popcolor
-% \math_accented_color_do_push
-% \fi
-% \ifx\p_math_accent_top\empty
-% \ifx\p_math_accent_bottom\empty
-% \else
-% \Umathaccent bottom \fam\zerocount\p_math_accent_bottom
-% \fi
-% \else
-% \ifx\p_math_accent_bottom\empty
-% \Umathaccent \fam\zerocount\p_math_accent_top
-% \else
-% \Umathaccent both \fam\zerocount\p_math_accent_top
-% \fam\zerocount\p_math_accent_bottom
-% \fi
-% \fi
-% {\popcolor#2}%
-% \stopusemathstyleparameter
-% \endgroup}
-%
-% \definemathaccent [myaccents] [\c!color=red]
-% \definemathaccent [mywidehat] [myaccents] [\c!top="0302]
-
-\installcorenamespace{mathaccents}
-
-\installcommandhandler \??mathaccents {mathaccents} \??mathaccents
-
-\setupmathaccents
- [\c!top=,
- \c!bottom=,
- \c!mathstyle=,
- \c!color=,
- \c!command=\v!yes]
-
-\definemathaccents
- [\v!both]
-
-\definemathaccents
- [\v!top]
- [\v!both]
-
-\definemathaccents
- [\v!bottom]
- [\v!both]
-
-\unexpanded\def\definemathtopaccent {\dotripleempty \math_accents_define_top }
-\unexpanded\def\definemathbottomaccent{\dotripleempty \math_accents_define_bottom}
-\unexpanded\def\definemathdoubleaccent{\doquadrupleempty\math_accents_define_double}
-
-\def\math_accents_define_top[#1][#2][#3]% class name top
- {\ifthirdargument
- \setuevalue{#2}{\math_accents_make_double {#1}\plusone{\number#3}\zerocount}%
- \else
- \setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusone{\number#2}\zerocount}%
- \fi}
-
-\def\math_accents_define_bottom[#1][#2][#3]% class name bottom
- {\ifthirdargument
- \setuevalue{#2}{\math_accents_make_double {#1}\plustwo\zerocount{\number#3}}%
- \else
- \setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plustwo\zerocount{\number#2}}%
- \fi}
-
-\def\math_accents_define_double[#1][#2][#3][#4]% class name top bottom
- {\iffourthargument
- \setuevalue{#2}{\math_accents_make_double {#1}\plusthree{\number#3}{\number#4}}%
- \else
- \setuevalue{#1}{\math_accents_make_double\noexpand\currentmathaccents\plusthree{\number#2}{\number#3}}%
- \fi}
-
-\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}
-
-\unexpanded\def\math_accents_make_double#class#kind#top#bottom#content%
- {\begingroup
- \edef\currentmathaccents {#class}%
- \edef\p_math_accent_color{\mathaccentsparameter\c!color}%
- \startusemathstyleparameter\mathaccentsparameter
- \ifx\p_math_accent_color\empty
- \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}
-
-\protect \endinput
diff --git a/tex/context/base/math-act.lua b/tex/context/base/math-act.lua
index fc63a0090..4f9b3b7e8 100644
--- a/tex/context/base/math-act.lua
+++ b/tex/context/base/math-act.lua
@@ -10,24 +10,19 @@ if not modules then modules = { } end modules ['math-act'] = {
local type, next = type, next
local fastcopy = table.fastcopy
-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 trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+local report_math = logs.reporter("mathematics","initializing")
-local report_math = logs.reporter("mathematics","initializing")
+local context = context
+local commands = commands
+local mathematics = mathematics
+local texdimen = tex.dimen
+local abs = math.abs
-local context = context
-local commands = commands
-local mathematics = mathematics
-local texsetdimen = tex.setdimen
-local abs = math.abs
-
-local sequencers = utilities.sequencers
-local appendgroup = sequencers.appendgroup
-local appendaction = sequencers.appendaction
-
-local fontchars = fonts.hashes.characters
+local sequencers = utilities.sequencers
+local appendgroup = sequencers.appendgroup
+local appendaction = sequencers.appendaction
local mathfontparameteractions = sequencers.new {
name = "mathparameters",
@@ -291,104 +286,14 @@ end
sequencers.appendaction("aftercopyingcharacters", "system","mathematics.overloaddimensions")
--- a couple of predefined tweaks:
+-- a couple of predefined tewaks:
local tweaks = { }
mathematics.tweaks = tweaks
--- function tweaks.fixbadprime(target,original)
--- target.characters[0xFE325] = target.characters[0x2032]
--- end
-
--- these could go to math-fbk
-
--- 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
--- local addprivate = fonts.helpers.addprivate
--- local olddata = characters[oldchr]
--- if olddata then
--- if swap then
--- swap = characters[swap]
--- height = swap.depth
--- depth = 0
--- else
--- height = height or 0
--- depth = depth or 0
--- end
--- local correction = swap and { "down", (olddata.height or 0) - height } or { "down", olddata.height }
--- local newdata = {
--- commands = { correction, { "slot", 1, oldchr } },
--- width = olddata.width,
--- height = height,
--- depth = depth,
--- }
--- characters[newchr] = newdata
--- local nextglyph = olddata.next
--- while nextglyph do
--- local oldnextdata = characters[nextglyph]
--- local newnextdata = {
--- commands = { correction, { "slot", 1, nextglyph } },
--- width = oldnextdata.width,
--- height = height,
--- depth = depth,
--- }
--- local newnextglyph = addprivate(target,formatters["original-%H"](nextglyph),newnextdata)
--- newdata.next = newnextglyph
--- local nextnextglyph = oldnextdata.next
--- if nextnextglyph == nextglyph then
--- break
--- else
--- olddata = oldnextdata
--- newdata = newnextdata
--- nextglyph = nextnextglyph
--- 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 = characters[oldglyph]
--- local newdata = {
--- commands = { correction, { "slot", 1, oldglyph } },
--- width = olddata.width,
--- height = height,
--- depth = depth,
--- }
--- hvi.glyph = addprivate(target,formatters["original-%H"](oldglyph),newdata)
--- end
--- end
--- end
--- -- end
--- end
-
--- function tweaks.fixoverline(target,original)
--- local height, depth = 0, 0
--- local mathparameters = target.mathparameters
--- if mathparameters then
--- height = mathparameters.OverbarVerticalGap
--- depth = mathparameters.UnderbarVerticalGap
--- else
--- height = target.parameters.xheight/4
--- depth = height
--- end
--- accent_to_extensible(target,0x203E,original,0x0305,height,depth)
--- -- also crappy spacing for our purpose: push to top of baseline
--- accent_to_extensible(target,0xFE3DE,original,0x23DE,height,depth,0x23DF)
--- accent_to_extensible(target,0xFE3DC,original,0x23DC,height,depth,0x23DD)
--- accent_to_extensible(target,0xFE3B4,original,0x23B4,height,depth,0x23B5)
--- -- for symmetry
--- target.characters[0xFE3DF] = original.characters[0x23DF]
--- target.characters[0xFE3DD] = original.characters[0x23DD]
--- target.characters[0xFE3B5] = original.characters[0x23B5]
--- -- inspect(fonts.helpers.expandglyph(target.characters,0x203E))
--- -- inspect(fonts.helpers.expandglyph(target.characters,0x23DE))
--- end
-
--- sequencers.appendaction("aftercopyingcharacters", "system","mathematics.tweaks.fixoverline") -- for the moment always
+function tweaks.fixbadprime(target,original)
+ target.characters[0xFE325] = target.characters[0x2032]
+end
-- helpers
@@ -396,7 +301,6 @@ local setmetatableindex = table.setmetatableindex
local family_font = node.family_font
local fontcharacters = fonts.hashes.characters
-local fontdescriptions = fonts.hashes.descriptions
local extensibles = utilities.storage.allocate()
fonts.hashes.extensibles = extensibles
@@ -420,34 +324,24 @@ local function extensiblecode(font,unicode)
if not character then
return unknown
end
- local first = character.next
local code = unicode
- local next = first
+ local next = character.next
while next do
code = next
character = characters[next]
next = character.next
end
local char = chardata[unicode]
- if not char then
- return unknown
- end
+ local mathextensible = char and char.mathextensible
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]
+ local e = mathextensible and extensibles[mathextensible]
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]
+ local e = mathextensible and extensibles[mathextensible]
return e and { e, code, character } or unknown
else
return unknown
@@ -480,199 +374,31 @@ end
-- abs(right["start"] - right["end"]) | right.advance | characters[right.glyph].width
function commands.horizontalcode(family,unicode)
- local font = family_font(family or 0)
- local data = extensibles[font][unicode]
- local kind = data[1]
- local loffset = 0
- local roffset = 0
+ local font = family_font(family or 0)
+ local data = extensibles[font][unicode]
+ local kind = data[1]
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
+ local characters = fontcharacters[font]
+ local left = charlist[1]
+ texdimen.scratchleftoffset = abs((left["start"] or 0) - (left["end"] or 0))
+ texdimen.scratchrightoffset = 0
elseif kind == e_right then
local charlist = data[3].horiz_variants
+ local characters = fontcharacters[font]
local right = charlist[#charlist]
- roffset = abs((right["start"] or 0) - (right["end"] or 0))
+ texdimen.scratchleftoffset = 0
+ texdimen.scratchrightoffset = abs((right["start"] or 0) - (right["end"] or 0))
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
+ local characters = fontcharacters[font]
+ local left = charlist[1]
+ local right = charlist[#charlist]
+ texdimen.scratchleftoffset = abs((left["start"] or 0) - (left["end"] or 0))
+ texdimen.scratchrightoffset = abs((right["start"] or 0) - (right["end"] or 0))
else
+ texdimen.scratchleftoffset = 0
+ texdimen.scratchrightoffset = 0
end
- texsetdimen("scratchleftoffset",loffset)
- texsetdimen("scratchrightoffset",roffset)
context(kind)
end
-
--- experiment
-
--- check: when true, only set when present in font
--- force: when false, then not set when already set
-
-local blocks = characters.blocks -- this will move to char-ini
-
-blocks["uppercasenormal"] = { first = 0x00041, last = 0x0005A }
-blocks["uppercasebold"] = { first = 0x1D400, last = 0x1D419 }
-blocks["uppercaseitalic"] = { first = 0x1D434, last = 0x1D44D }
-blocks["uppercasebolditalic"] = { first = 0x1D468, last = 0x1D481 }
-blocks["uppercasescript"] = { first = 0x1D49C, last = 0x1D4B5 }
-blocks["uppercaseboldscript"] = { first = 0x1D4D0, last = 0x1D4E9 }
-blocks["uppercasefraktur"] = { first = 0x1D504, last = 0x1D51D }
-blocks["uppercasedoublestruck"] = { first = 0x1D538, last = 0x1D551 }
-blocks["uppercaseboldfraktur"] = { first = 0x1D56C, last = 0x1D585 }
-blocks["uppercasesansserifnormal"] = { first = 0x1D5A0, last = 0x1D5B9 }
-blocks["uppercasesansserifbold"] = { first = 0x1D5D4, last = 0x1D5ED }
-blocks["uppercasesansserifitalic"] = { first = 0x1D608, last = 0x1D621 }
-blocks["uppercasesansserifbolditalic"] = { first = 0x1D63C, last = 0x1D655 }
-blocks["uppercasemonospace"] = { first = 0x1D670, last = 0x1D689 }
-blocks["uppercasegreeknormal"] = { first = 0x00391, last = 0x003AA }
-blocks["uppercasegreekbold"] = { first = 0x1D6A8, last = 0x1D6C1 }
-blocks["uppercasegreekitalic"] = { first = 0x1D6E2, last = 0x1D6FB }
-blocks["uppercasegreekbolditalic"] = { first = 0x1D71C, last = 0x1D735 }
-blocks["uppercasegreeksansserifbold"] = { first = 0x1D756, last = 0x1D76F }
-blocks["uppercasegreeksansserifbolditalic"] = { first = 0x1D790, last = 0x1D7A9 }
-
-blocks["lowercasenormal"] = { first = 0x00061, last = 0x0007A }
-blocks["lowercasebold"] = { first = 0x1D41A, last = 0x1D433 }
-blocks["lowercaseitalic"] = { first = 0x1D44E, last = 0x1D467 }
-blocks["lowercasebolditalic"] = { first = 0x1D482, last = 0x1D49B }
-blocks["lowercasescript"] = { first = 0x1D4B6, last = 0x1D4CF }
-blocks["lowercaseboldscript"] = { first = 0x1D4EA, last = 0x1D503 }
-blocks["lowercasefraktur"] = { first = 0x1D51E, last = 0x1D537 }
-blocks["lowercasedoublestruck"] = { first = 0x1D552, last = 0x1D56B }
-blocks["lowercaseboldfraktur"] = { first = 0x1D586, last = 0x1D59F }
-blocks["lowercasesansserifnormal"] = { first = 0x1D5BA, last = 0x1D5D3 }
-blocks["lowercasesansserifbold"] = { first = 0x1D5EE, last = 0x1D607 }
-blocks["lowercasesansserifitalic"] = { first = 0x1D622, last = 0x1D63B }
-blocks["lowercasesansserifbolditalic"] = { first = 0x1D656, last = 0x1D66F }
-blocks["lowercasemonospace"] = { first = 0x1D68A, last = 0x1D6A3 }
-blocks["lowercasegreeknormal"] = { first = 0x003B1, last = 0x003CA }
-blocks["lowercasegreekbold"] = { first = 0x1D6C2, last = 0x1D6DB }
-blocks["lowercasegreekitalic"] = { first = 0x1D6FC, last = 0x1D715 }
-blocks["lowercasegreekbolditalic"] = { first = 0x1D736, last = 0x1D74F }
-blocks["lowercasegreeksansserifbold"] = { first = 0x1D770, last = 0x1D789 }
-blocks["lowercasegreeksansserifbolditalic"] = { first = 0x1D7AA, last = 0x1D7C3 }
-
-blocks["digitsnormal"] = { first = 0x00030, last = 0x00039 }
-blocks["digitsbold"] = { first = 0x1D7CE, last = 0x1D7D8 }
-blocks["digitsdoublestruck"] = { first = 0x1D7D8, last = 0x1D7E2 }
-blocks["digitssansserifnormal"] = { first = 0x1D7E2, last = 0x1D7EC }
-blocks["digitssansserifbold"] = { first = 0x1D7EC, last = 0x1D805 }
-blocks["digitsmonospace"] = { first = 0x1D7F6, last = 0x1D80F }
-
-blocks["mathematicaloperators"] = { first = 0x02200, last = 0x022FF }
-blocks["miscellaneousmathematicalsymbolsa"] = { first = 0x027C0, last = 0x027EF }
-blocks["miscellaneousmathematicalsymbolsb"] = { first = 0x02980, last = 0x029FF }
-blocks["supplementalmathematicaloperators"] = { first = 0x02A00, last = 0x02AFF }
-blocks["letterlikesymbols"] = { first = 0x02100, last = 0x0214F }
-blocks["miscellaneoustechnical"] = { first = 0x02308, last = 0x0230B }
-blocks["geometricshapes"] = { first = 0x025A0, last = 0x025FF }
-blocks["miscellaneoussymbolsandarrows"] = { first = 0x02B30, last = 0x02B4C }
-blocks["mathematicalalphanumericsymbols"] = { first = 0x00400, last = 0x1D7FF }
-
-blocks["digitslatin"] = { first = 0x00030, last = 0x00039 }
-blocks["digitsarabicindic"] = { first = 0x00660, last = 0x00669 }
-blocks["digitsextendedarabicindic"] = { first = 0x006F0, last = 0x006F9 }
-------["digitsdevanagari"] = { first = 0x00966, last = 0x0096F }
-------["digitsbengali"] = { first = 0x009E6, last = 0x009EF }
-------["digitsgurmukhi"] = { first = 0x00A66, last = 0x00A6F }
-------["digitsgujarati"] = { first = 0x00AE6, last = 0x00AEF }
-------["digitsoriya"] = { first = 0x00B66, last = 0x00B6F }
-------["digitstamil"] = { first = 0x00030, last = 0x00039 } -- no zero
-------["digitstelugu"] = { first = 0x00C66, last = 0x00C6F }
-------["digitskannada"] = { first = 0x00CE6, last = 0x00CEF }
-------["digitsmalayalam"] = { first = 0x00D66, last = 0x00D6F }
-------["digitsthai"] = { first = 0x00E50, last = 0x00E59 }
-------["digitslao"] = { first = 0x00ED0, last = 0x00ED9 }
-------["digitstibetan"] = { first = 0x00F20, last = 0x00F29 }
-------["digitsmyanmar"] = { first = 0x01040, last = 0x01049 }
-------["digitsethiopic"] = { first = 0x01369, last = 0x01371 }
-------["digitskhmer"] = { first = 0x017E0, last = 0x017E9 }
-------["digitsmongolian"] = { first = 0x01810, last = 0x01809 }
-
--- operators : 0x02200
--- symbolsa : 0x02701
--- symbolsb : 0x02901
--- supplemental : 0x02A00
-
--- todo: tounicode
-
-function mathematics.injectfallbacks(target,original)
- local properties = original.properties
- if properties and properties.hasmath then
- local specification = target.specification
- if specification then
- local fallbacks = specification.fallbacks
- if fallbacks then
- local definitions = fonts.collections.definitions[fallbacks]
- if definitions 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
- target.type = "virtual"
- target.properties.virtualized = true
- end
- if #fonts == 0 then
- fonts[1] = { id = 0, size = size } -- sel, 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 check = definition.check
- local force = definition.force
- local rscale = definition.rscale or 1
- local offset = definition.offset or start
- local id = definedfont { name = name, size = size * rscale }
- local index = #fonts + 1
- fonts[index] = { id = id, size = size }
- local chars = fontchars[id]
- if check then
- for unicode = start, stop do
- local unic = unicode + offset - start
- if not chars[unicode] then
- -- not in font
- elseif force or (not done[unic] and not characters[unic]) then
- if trace_collecting then
- report_math("remapping math character, vector %a, font %a, character %C, %s",fallbacks,name,unic,"checked")
- end
- characters[unic] = copiedglyph(target,characters,chars,unicode,index)
- done[unic] = true
- end
- end
- else
- for unicode = start, stop do
- local unic = unicode + offset - start
- if force or (not done[unic] and not characters[unic]) then
- if trace_collecting then
- report_math("remapping math character, vector %a, font %a, character %C, %s",fallbacks,name,unic,"unchecked")
- end
- characters[unic] = copiedglyph(target,characters,chars,unicode,index)
- done[unic] = true
- end
- end
- end
- end
- end
- end
- end
- end
-end
-
-sequencers.appendaction("aftercopyingcharacters", "system","mathematics.injectfallbacks")
diff --git a/tex/context/base/math-ali.mkiv b/tex/context/base/math-ali.mkiv
index 911a0d430..db960de26 100644
--- a/tex/context/base/math-ali.mkiv
+++ b/tex/context/base/math-ali.mkiv
@@ -25,7 +25,7 @@
%D Modules may provide additional alignment features. The following
%D mechanisms are provided by the core.
-% n>1 ### needed, strange # interaction in recurse
+% n>1 #### needed, strange # interaction in recurse
\newtoks\c_math_align_a
\newtoks\c_math_align_b
@@ -39,9 +39,9 @@
\def\math_build_eqalign_step
{\ifnum\recurselevel>\plusone
%\appendtoks
- % \tabskip\mathalignmentparameter\c!distance\aligntab\tabskip\zeropoint
+ % \tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint
%\to\scratchtoks
- \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance\aligntab\tabskip\zeropoint}%
+ \scratchtoks\expandafter{\the\scratchtoks\tabskip\mathalignmentparameter\c!distance&\tabskip\zeropoint}%
\fi
\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
\dorecurse{\numexpr\mathalignmentparameter\c!n-\plusone\relax}
@@ -56,9 +56,9 @@
{\emptyhbox
\mskip\thinmuskip
\vcenter
- {\math_openup\displayopenupvalue % was: \openup\jot
+ {\openup\displayopenupvalue % was: \openup\jot
\mathsurround\zeropoint
- \ialign{\strut\hfil$\displaystyle{\alignmark\alignmark}$\aligntab$\displaystyle{{}\alignmark\alignmark{}}$\hfil\crcr#1\crcr}}%
+ \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##{}}$\hfil\crcr#1\crcr}}%
\mskip\thinmuskip}
% preamble is scanned for tabskips so we need the span to prevent an error message
@@ -68,14 +68,14 @@
% use zeroskipplusfill
\def\math_prepare_r_eqalign_no
- {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}%
- \c_math_align_b{\aligntab\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
\ifnum\mathraggedstatus=\plusone
- \c_math_align_c{\hfil\aligntab\span\math_text_in_eqalign{\alignmark\alignmark}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else\ifnum\mathraggedstatus=\plusthree
- \c_math_align_c{\hfil\tabskip\zeropoint\s!plus 1\s!fill\aligntab\span\math_text_in_eqalign{\alignmark\alignmark}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\s!plus 1\s!fill&\span\math_text_in_eqalign{##}\tabskip\zeropoint}%
\else
- \c_math_align_c{\hfil\tabskip\centering\aligntab\llap{\span\math_text_in_eqalign{\alignmark\alignmark}}\tabskip\zeropoint}%
+ \c_math_align_c{\hfil\tabskip\centering&\llap{\span\math_text_in_eqalign{##}}\tabskip\zeropoint}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -83,15 +83,15 @@
\tabskip\centering}
\def\math_prepare_l_eqalign_no
- {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}%
- \c_math_align_b{\aligntab\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{\alignmark\alignmark}\math_right_of_eqalign\tabskip\zeropoint}%
+ {\c_math_align_a{\strut\math_first_in_eqalign\hfil\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
+ \c_math_align_b{&\math_next_in_eqalign\math_left_of_equalign\span\math_math_in_eqalign{##}\math_right_of_eqalign\tabskip\zeropoint}%
% problem: number is handled after rest and so ends up in the margin
\ifnum\mathraggedstatus=\plusone
- \c_math_align_c{\hfil\aligntab\kern-\displaywidth\rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else\ifnum\mathraggedstatus=\plusthree
- \c_math_align_c{\hfil\tabskip\zeropoint\s!plus 1\s!fill\aligntab\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\zeropoint\s!plus 1\s!fill&\kern-\displaywidth\span\math_rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\else
- \c_math_align_c{\hfil\tabskip\centering\aligntab\kern-\displaywidth\rlap{\span\math_text_in_eqalign{\alignmark\alignmark}}\tabskip\displaywidth}%
+ \c_math_align_c{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\math_text_in_eqalign{##}}\tabskip\displaywidth}%
\fi\fi
\global\mathnumberstatus\zerocount
\math_build_eqalign
@@ -192,7 +192,7 @@
\c_math_eqalign_column\zerocount
\processcommacommand
[\mathalignmentparameter\c!align]
- {\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}% takes argument
+ {\advance\c_math_eqalign_column\plusone\doseteqaligncolumn}% takes argument
\global\c_math_eqalign_column\plusone
\dostarttagged\t!math\empty
\dostarttagged\t!mathtable\currentmathalignment
@@ -286,7 +286,7 @@
\fi
\fi}
-\def\math_eqalign_set_column#1% we could just add to the preamble (as with other alignments)
+\def\doseteqaligncolumn#1% we could just add to the preamble (as with other alignments)
{\expandafter\let\csname\??mathalignmentvariant\number\c_math_eqalign_column\expandafter\endcsname
\csname\??mathalignmentvariant\ifcsname\??mathalignmentvariant#1\endcsname#1\else\v!normal\fi\endcsname}
@@ -594,8 +594,6 @@
\setvalue {\e!stop \currentmathmatrix}{\math_matrix_stop}% no u else lookahead problem
\to \everydefinemathmatrix
-\let\math_matrix_NC\relax
-
\unexpanded\def\math_matrix_start#1%
{\begingroup
\edef\currentmathmatrix{#1}%
@@ -609,12 +607,12 @@
\math_matrix_align_method_analyze
\mathmatrixleft
\mathmatrixbox\bgroup
- \pushmacro\math_matrix_NC
+ \pushmacro\domatrixNC
\let\endmath\relax
- \def\NC{\math_matrix_NC}%
- \def\MC{\math_matrix_NC\ifmmode\else\startimath\let\endmath\stopimath\fi}%
- \global\let\math_matrix_NC\math_matrix_NC_indeed
- \def\NR{\endmath\global\let\math_matrix_NC\math_matrix_NC_indeed\crcr}%
+ \def\NC{\domatrixNC}%
+ \def\MC{\domatrixNC\ifmmode\else$\def\endmath{$}\fi}%
+ \global\let\domatrixNC\dodomatrixNC
+ \def\NR{\endmath\global\let\domatrixNC\dodomatrixNC\crcr}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
@@ -622,8 +620,8 @@
\c_math_eqalign_column\zerocount
\processcommacommand
[\mathmatrixparameter\c!align]
- {\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}%
- \scratchcounter\ifnum\c_math_eqalign_column>\zerocount \c_math_eqalign_column \else \plusone \fi
+ {\advance\c_math_eqalign_column\plusone\doseteqaligncolumn}% was \dosetmatrixcolumn
+ \scratchcounter=\ifnum\c_math_eqalign_column>\zerocount \c_math_eqalign_column \else \plusone \fi
\global\c_math_eqalign_column\plusone
\math_matrix_prepare}
@@ -632,7 +630,7 @@
\mathstrut\crcr
\noalign{\kern-\baselineskip}%
\egroup
- \popmacro\math_matrix_NC
+ \popmacro\domatrixNC
\egroup
\mathmatrixright
\endgroup}
@@ -642,13 +640,13 @@
\def\math_matrix_prepare
{\c_math_align_a{\strut\math_first_in_eqalign\math_left_of_equalign\span
- \math_text_in_eqalign{\mathmatrixparameter\c!style\alignmark\alignmark}\math_right_of_eqalign}%
- \c_math_align_b{\aligntab\hskip\mathmatrixparameter\c!distance
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
+ \c_math_align_b{&\hskip\mathmatrixparameter\c!distance
\math_next_in_eqalign\math_left_of_equalign\span
- \math_text_in_eqalign{\mathmatrixparameter\c!style\alignmark\alignmark}\math_right_of_eqalign}%
- \c_math_align_c{\aligntab\aligntab\hskip\mathmatrixparameter\c!distance
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
+ \c_math_align_c{&&\hskip\mathmatrixparameter\c!distance
\math_left_of_equalign\span
- \math_text_in_eqalign{\mathmatrixparameter\c!style\alignmark\alignmark}\math_right_of_eqalign}%
+ \math_text_in_eqalign{\mathmatrixparameter\c!style##}\math_right_of_eqalign}%
\scratchtoks\emptytoks
\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_a}}%
\dorecurse{\numexpr\scratchcounter-\plusone\relax}
@@ -656,8 +654,8 @@
\normalexpanded{\scratchtoks{\the\scratchtoks\the\c_math_align_c}}%
\halign \expandafter \bgroup\the\scratchtoks \crcr}
-\unexpanded\def\math_matrix_NC_indeed
- {\gdef\math_matrix_NC{\endmath\aligntab}}
+\unexpanded\def\dodomatrixNC
+ {\gdef\domatrixNC{\endmath&}}
\installcorenamespace{mathmatrixalignmethod}
@@ -879,16 +877,16 @@
\lineskip\mathstackvgap
\lineskiplimit\lineskip
\let\stopmathmode\relax
- \def\NC{\math_matrix_NC}%
- \def\MC{\math_matrix_NC\startmathmode}%
- \global\let\math_matrix_NC\math_matrix_NC_indeed
+ \def\NC{\domatrixNC}%
+ \def\MC{\domatrixNC\startmathmode}%
+ \global\let\domatrixNC\dodomatrixNC
\def\NR
{\stopmathmode
- \global\let\math_matrix_NC\math_matrix_NC_indeed
+ \global\let\domatrixNC\dodomatrixNC
\crcr}%
\mathsurround\zeropoint
\everycr\emptytoks
- \halign\bgroup\hfil$\scriptstyle\alignmark\alignmark$\hfil\crcr}
+ \halign\bgroup\hfil$\scriptstyle##$\hfil\crcr}
\def\stopsubstack
{\crcr
diff --git a/tex/context/base/math-def.mkiv b/tex/context/base/math-def.mkiv
index 250986959..9201fc540 100644
--- a/tex/context/base/math-def.mkiv
+++ b/tex/context/base/math-def.mkiv
@@ -15,7 +15,7 @@
\unprotect
-%D Some day this will be done at the lua end.
+% this will be done at the lua end
\startluacode
mathematics.define(\number\defaultmathfamily)
@@ -24,8 +24,22 @@
\activatemathcharacters
-%D The \mfunction macro is an alternative for \hbox with a controlable font
-%D switch.
+% will go to math-ext (if used at all)
+
+\Umathchardef\braceld=0 \defaultmathfamily "FF07A
+\Umathchardef\bracerd=0 \defaultmathfamily "FF07B
+\Umathchardef\bracelu=0 \defaultmathfamily "FF07C
+\Umathchardef\braceru=0 \defaultmathfamily "FF07D
+
+% ctx specific
+
+% \bgroup
+% \catcode`|=\othercatcode
+% \global\let\|=|
+% \egroup
+
+% The \mfunction macro is an alternative for \hbox with a
+% controlable font switch.
\definemathcommand [arccos] [nolop] {\mfunctionlabeltext{arccos}}
\definemathcommand [arcsin] [nolop] {\mfunctionlabeltext{arcsin}}
@@ -55,7 +69,7 @@
\definemathcommand [max] [limop] {\mfunctionlabeltext{max}}
\definemathcommand [min] [limop] {\mfunctionlabeltext{min}}
\definemathcommand [mod] [limop] {\mfunctionlabeltext{mod}}
-%definemathcommand [div] [limop] {\mfunctionlabeltext{div}} % overloads \div symbol
+%definemathcommand [div] [limop] {\mfunctionlabeltext{div}} % overloads \div symbol
\definemathcommand [projlim] [limop] {\mfunctionlabeltext{projlim}}
\definemathcommand [Pr] [limop] {\mfunctionlabeltext{Pr}}
\definemathcommand [sec] [nolop] {\mfunctionlabeltext{sec}}
@@ -65,23 +79,157 @@
\definemathcommand [tanh] [nolop] {\mfunctionlabeltext{tanh}}
\definemathcommand [tan] [nolop] {\mfunctionlabeltext{tan}}
+% \definemathcommand [integers] {{\mathblackboard Z}}
+% \definemathcommand [reals] {{\mathblackboard R}}
+% \definemathcommand [rationals] {{\mathblackboard Q}}
+% \definemathcommand [naturalnumbers]{{\mathblackboard N}}
+% \definemathcommand [complexes] {{\mathblackboard C}}
+% \definemathcommand [primes] {{\mathblackboard P}}
+
\let\normalmatharg\arg % todo: maybe automatically
+% using attributes
+
+\setnewconstant\bigmathdelimitermethod\plusone
+
+\def\plainbigdelimiters % traditional method
+ {\bigmathdelimitermethod\plustwo}
+
+\plainbigdelimiters % is default for the moment but not so nice
+
+\def\doplainbigmath#1#2%
+ {{\hbox{$%
+ \nulldelimiterspace\zeropoint\relax
+ \mathsurround\zeropoint
+ $}}}
+
+\def\doleftbigmath #1{\ifx#1\relax\else\left#1\expandafter\doleftbigmath \fi}
+\def\dorightbigmath#1{\ifx#1\relax\else\right.\expandafter\dorightbigmath\fi}
+
+\installcorenamespace{mathbig}
+
+\unexpanded\def\choosemathbig#1#2% so we accent \big{||} as well
+ {{\hbox{$%
+ \ifcase\bigmathdelimitermethod
+ \doleftbigmath#2\relax
+ \dorightbigmath#2\relax
+ \or
+ \attribute\mathsizeattribute#1\relax
+ \doleftbigmath#2\relax
+ \dorightbigmath#2\relax
+ \else
+ \doleftbigmath#2\relax
+ \vbox to\getvalue{\??mathbig\number#1}\bodyfontsize{}%
+ \dorightbigmath#2\relax
+ \fi
+ \nulldelimiterspace\zeropoint\relax
+ \mathsurround\zeropoint
+ $}}}
+
+\definemathcommand [big] {\choosemathbig\plusone } \setvalue{\??mathbig1}{0.85}
+\definemathcommand [Big] {\choosemathbig\plustwo } \setvalue{\??mathbig2}{1.15}
+\definemathcommand [bigg] {\choosemathbig\plusthree} \setvalue{\??mathbig3}{1.45}
+\definemathcommand [Bigg] {\choosemathbig\plusfour } \setvalue{\??mathbig4}{1.75}
+
+\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}
+
%D This needs checking:
-\unexpanded\def\setoperatorlimits#1#2% operator limits
+\def\setoperatorlimits#1#2% operator limits
{\savenormalmeaning{#1}%
- \expandafter\def\expandafter#1\expandafter{\csname normal\strippedcsname#1\endcsname#2}}
-
-\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
+ \def#1{\csname normal\strippedcsname#1\endcsname#2}}
+
+\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
+
+%D This is a temporary hack until we figure out how to do this correctly,
+%D preferably using math parameters but we can also consider doing some
+%D node juggling here.
+
+\unexpanded\def\implies {\mathrel{\;\Longrightarrow\;}}
+\unexpanded\def\impliedby{\mathrel{\;\Longleftarrow\;}}
+\unexpanded\def\And {\mathrel{\;\internalAnd\;}}
+%unexpanded\def\iff {\;\Longleftrightarrow\;}
+\setuvalue {iff}{\;\Longleftrightarrow\;} % nicer for if checker
+
+% todo: virtual in math-vfu
+
+% \definemathcommand [mapsto] {\mapstochar\rightarrow}
+% \definemathcommand [hookrightarrow] {\lhook\joinrel\rightarrow}
+% \definemathcommand [hookleftarrow] {\leftarrow\joinrel\rhook}
+% \definemathcommand [bowtie] {\mathrel\triangleright\joinrel\mathrel\triangleleft}
+% \definemathcommand [models] {\mathrel|\joinrel=}
+% \definemathcommand [iff] {\;\Longleftrightarrow\;}
+
+% hm
+
+% ldots = 2026
+% vdots = 22EE
+% cdots = 22EF
+% ddots = 22F1
+% udots = 22F0
+
+% \def\PLAINldots{\ldotp\ldotp\ldotp}
+% \def\PLAINcdots{\cdotp\cdotp\cdotp}
+
+% \def\PLAINvdots
+% {\vbox{\baselineskip.4\bodyfontsize\lineskiplimit\zeropoint\kern.6\bodyfontsize\hbox{.}\hbox{.}\hbox{.}}}
+
+% \def\PLAINddots
+% {\mkern1mu%
+% \raise.7\bodyfontsize\vbox{\kern.7\bodyfontsize\hbox{.}}%
+% \mkern2mu%
+% \raise.4\bodyfontsize\relax\hbox{.}%
+% \mkern2mu%
+% \raise.1\bodyfontsize\hbox{.}%
+% \mkern1mu}
+
+% \definemathcommand [ldots] [inner] {\PLAINldots}
+% \definemathcommand [cdots] [inner] {\PLAINcdots}
+% \definemathcommand [vdots] [nothing] {\PLAINvdots}
+% \definemathcommand [ddots] [inner] {\PLAINddots}
+
+%D \starttyping
+%D $\sqrt[3]{10}$
+%D \stoptyping
+
+\def\rootradical{\Uroot \defaultmathfamily "221A } % can be done in char-def
+
+\def\root#1\of{\rootradical{#1}} % #2
+
+\unexpanded\def\sqrt{\doifnextoptionalelse\rootwithdegree\rootwithoutdegree}
+
+\def\rootwithdegree [#1]{\rootradical{#1}}
+\def\rootwithoutdegree {\rootradical {}}
+
+\definemathcommand [mathstrut] {\vphantom{(}}
+\definemathcommand [joinrel] {\mathrel{\mkern-3mu}}
+
+\unexpanded\def\{{\mathortext\lbrace\letterleftbrace } % or maybe a chardef
+\unexpanded\def\}{\mathortext\rbrace\letterrightbrace} % or maybe a chardef
+\unexpanded\def\|{\mathortext\vert \letterbar } % or maybe a chardef
+
+%D The following colon related definitions are provided by Aditya
+%D Mahajan who derived them from \type {mathtools.sty} and \type
+%D {colonequals.sty}.
%D \macros
%D {centercolon, colonminus, minuscolon, colonequals, equalscolon,
@@ -90,11 +238,6 @@
%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
@@ -120,13 +263,16 @@
%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.
\definemathcommand [colonsep] {\mkern-1.2mu}
\definemathcommand [doublecolonsep] {\mkern-0.9mu}
+%D Now we define all the colon relations .. needs checking with char-def.lua ...
+%d will move to a separate module.
+
\definemathcommand [centercolon] [rel] {\mathstylevcenteredhbox\colon}
\definemathcommand [colonminus] [rel] {\centercolon\colonsep\mathrel{-}}
\definemathcommand [minuscolon] [rel] {\mathrel{-}\colonsep\centercolon} % native char
@@ -147,6 +293,93 @@
\definemathcommand [colonsim] [rel] {\coloncolon\colonsep\sim}
\definemathcommand [simcoloncolon] [rel] {\sim\coloncolon\colonsep}
+%D Goodies. We might move this elsewhere.
+
+% 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
+
+\unexpanded\def\underleftarrow #1{\mathop{\Uunderdelimiter \defaultmathfamily "2190 {#1}}}
+\unexpanded\def\overleftarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2190 {#1}}}
+\unexpanded\def\underrightarrow#1{\mathop{\Uunderdelimiter \defaultmathfamily "2192 {#1}}}
+\unexpanded\def\overrightarrow #1{\mathop{\Uoverdelimiter \defaultmathfamily "2192 {#1}}}
+
+% watch out: here we have a class (zero):
+
+\unexpanded\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF }
+\unexpanded\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD }
+
+% let's keep this
+
+\def\Umathbotaccent{\Umathaccent \s!bottom }
+\def\Umathaccents {\Umathaccent \s!both }
+
+\let\normaloverbrace \overbrace
+\let\normalunderbrace \underbrace
+\let\normaloverparent \overparent
+\let\normalunderparent \underparent
+\let\normaloverbracket \overbracket
+\let\normalunderbracket \underbracket
+\let\normalunderleftarrow \underleftarrow
+\let\normaloverleftarrow \overleftarrow
+\let\normalunderrightarrow\underrightarrow
+\let\normaloverrightarrow \overrightarrow
+
+\unexpanded\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
+\unexpanded\def\stackrel #1#2{\mathrel{\mathop{#2}\limits^{#1}}}
+
+\unexpanded\def\overbrace {\mathopwithlimits\normaloverbrace }
+\unexpanded\def\underbrace {\mathopwithlimits\normalunderbrace }
+\unexpanded\def\doublebrace {\mathopwithlimits\normaldoublebrace }
+\unexpanded\def\overparent {\mathopwithlimits\normaloverparent }
+\unexpanded\def\underparent {\mathopwithlimits\normalunderparent }
+\unexpanded\def\overbracket {\mathopwithlimits\normaloverbracket }
+\unexpanded\def\underbracket {\mathopwithlimits\normalunderbracket }
+\unexpanded\def\doubleparent {\mathopwithlimits\normaldoubleparent }
+\unexpanded\def\underleftarrow {\mathopwithlimits\normalunderleftarrow }
+\unexpanded\def\overleftarrow {\mathopwithlimits\normaloverleftarrow }
+\unexpanded\def\underrightarrow{\mathopwithlimits\normalunderrightarrow}
+\unexpanded\def\overrightarrow {\mathopwithlimits\normaloverrightarrow }
+
+\let\lceil \lceiling
+\let\rceil \rceiling
+
+\let\normalsurd\surd
+
+\unexpanded\def\surd{\normalsurd{}}
+
+% Some special characters:
+
+\unexpanded\def\nabla{∇} % this one adapts
+
+%
+% todo mathclass=punctuation ord
+
+% \Umathcode"02C="6 \defaultmathfamily "02C
+% \Umathcode"02E="0 \defaultmathfamily "02E
+
+% tricky .. todo
+
% \appendtoks
% \def\over{\primitive\over}%
% \to \everymathematics
diff --git a/tex/context/base/math-dir.lua b/tex/context/base/math-dir.lua
deleted file mode 100644
index 507a24e41..000000000
--- a/tex/context/base/math-dir.lua
+++ /dev/null
@@ -1,145 +0,0 @@
-if not modules then modules = { } end modules ['math-dir'] = {
- version = 1.001,
- comment = "companion to typo-dir.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- As I'm wrapping up the updated math support (for CTX/TUG 2013) I wondered about numbers in
--- r2l math mode. Googling lead me to TUGboat, Volume 25 (2004), No. 2 where I see numbers
--- running from left to right. Makes me wonder how far we should go. And as I was looking
--- into bidi anyway, it's a nice distraction.
---
--- I first tried to hook something into noads but that gets pretty messy due to indirectness
--- char noads. If needed, I'll do it that way. With regards to spacing: as we can assume that
--- only numbers are involved we can safely swap them and the same is true for mirroring. But
--- anyway, I'm not too happy with this solution so eventually I'll do something with noads (as
--- an alternative method). Yet another heuristic approach.
-
-local nodes, node = nodes, node
-
-local trace_directions = false trackers.register("typesetters.directions.math", function(v) trace_directions = v end)
-
-local report_directions = logs.reporter("typesetting","math directions")
-
-local insert_node_before = nodes.insert_before
-local insert_node_after = nodes.insert_after
-
-local nodecodes = nodes.nodecodes
-local tasks = nodes.tasks
-
-local glyph_code = nodecodes.glyph
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-
-local nodepool = nodes.pool
-
-local new_textdir = nodepool.textdir
-
-local chardirections = characters.directions
-local charmirrors = characters.mirrors
-local charclasses = characters.textclasses
-
-local directions = typesetters.directions or { }
-
-local a_mathbidi = attributes.private('mathbidi')
-
-local function processmath(head)
- local current = head
- local done = false
- local start = nil
- local stop = nil
- local function capsulate()
- head = insert_node_before(head,start,new_textdir("+TLT"))
- insert_node_after(head,stop,new_textdir("-TLT"))
- if trace_directions then
- report_directions("reversed: %s",nodes.listtoutf(start,false,false,stop))
- end
- done = true
- start = false
- stop = nil
- end
- while current do
- local id = current.id
- if id == glyph_code then
- local char = current.char
- local cdir = chardirections[char]
- if cdir == "en" or cdir == "an" then -- we could check for mathclass punctuation
- if not start then
- start = current
- end
- stop = current
- else
- if not start then
- -- nothing
- elseif start == stop then
- start = nil
- else
- capsulate()
- end
- if cdir == "on" then
- local mirror = charmirrors[char]
- if mirror then
- local class = charclasses[char]
- if class == "open" or class == "close" then
- current.char = mirror
- if trace_directions then
- report_directions("mirrored: %C to %C",char,mirror)
- end
- done = true
- end
- end
- end
- end
- elseif not start then
- -- nothing
- elseif start == stop then
- start = nil
- else
- capsulate(head,start,stop)
- -- math can pack things into hlists .. we need to make sure we don't process
- -- too often: needs checking
- if id == hlist_code or id == vlist_code then
- local list, d = processmath(current.list)
- current.list = list
- if d then
- done = true
- end
- end
- end
- current = current.next
- end
- if not start then
- -- nothing
- elseif start == stop then
- -- nothing
- else
- capsulate()
- end
- return head, done
-end
-
-local enabled = false
-
-function directions.processmath(head) -- style, penalties
- if enabled then
- local a = head[a_mathbidi]
- if a and a > 0 then
- return processmath(head)
- end
- end
- return head, false
-end
-
-function directions.setmath(n)
- if not enabled and n and n > 0 then
- if trace_directions then
- report_directions("enabling directions handler")
- end
- tasks.enableaction("math","typesetters.directions.processmath")
- enabled = true
- end
-end
-
-commands.setmathdirection = directions.setmath
diff --git a/tex/context/base/math-fbk.lua b/tex/context/base/math-fbk.lua
index b364d1208..eebc4e4e7 100644
--- a/tex/context/base/math-fbk.lua
+++ b/tex/context/base/math-fbk.lua
@@ -6,20 +6,17 @@ if not modules then modules = { } end modules ['math-fbk'] = {
license = "see context related readme files"
}
-local trace_fallbacks = false trackers.register("math.fallbacks", function(v) trace_fallbacks = v end)
+local trace_fallbacks = false trackers.register("math.fallbacks", function(v) trace_fallbacks = v end)
-local report_fallbacks = logs.reporter("math","fallbacks")
+local report_fallbacks = logs.reporter("math","fallbacks")
-local formatters = string.formatters
-local fastcopy = table.fastcopy
-
-local fallbacks = { }
-mathematics.fallbacks = fallbacks
+local fallbacks = { }
+mathematics.fallbacks = fallbacks
local virtualcharacters = { }
-local identifiers = fonts.hashes.identifiers
-local lastmathids = fonts.hashes.lastmathids
+local identifiers = fonts.hashes.identifiers
+local lastmathids = fonts.hashes.lastmathids
-- we need a trick (todo): if we define scriptscript, script and text in
-- that order we could use their id's .. i.e. we could always add a font
@@ -28,11 +25,6 @@ local lastmathids = fonts.hashes.lastmathids
--
-- todo: use index 'true when luatex provides that feature (on the agenda)
--- to be considered:
---
--- in luatex provide reserve_id (and pass id as field of tfmdata)
--- in context define three sizes but pass them later i.e. do virtualize afterwards
-
function fallbacks.apply(target,original)
local mathparameters = target.mathparameters -- why not hasmath
if mathparameters then
@@ -47,7 +39,7 @@ function fallbacks.apply(target,original)
end
-- This is not okay yet ... we have no proper way to refer to 'self'
-- otherwise I will make my own id allocator).
- local self = #usedfonts == 0 and font.nextid() or nil -- will be true
+local self = #usedfonts == 0 and font.nextid() or nil -- will be true
local textid, scriptid, scriptscriptid
local textindex, scriptindex, scriptscriptindex
local textdata, scriptdata, scriptscriptdata
@@ -56,27 +48,26 @@ function fallbacks.apply(target,original)
-- textid = nil -- self
-- scriptid = nil -- no smaller
-- scriptscriptid = nil -- no smaller
- textid = self
- scriptid = self
- scriptscriptid = self
+textid = self
+scriptid = self
+scriptscriptid = self
elseif mathsize == 2 then
-- scriptsize
-- textid = nil -- self
- textid = self
+textid = self
scriptid = lastmathids[3]
scriptscriptid = lastmathids[3]
else
-- textsize
-- textid = nil -- self
- textid = self
+textid = self
scriptid = lastmathids[2]
scriptscriptid = lastmathids[3]
end
if textid then
textindex = #usedfonts + 1
usedfonts[textindex] = { id = textid }
--- textdata = identifiers[textid] or target
- textdata = target
+ textdata = identifiers[textid]
else
textdata = target
end
@@ -96,7 +87,8 @@ function fallbacks.apply(target,original)
scriptscriptindex = scriptindex
scriptscriptdata = scriptdata
end
- -- report_fallbacks("used textid: %S, used script id: %S, used scriptscript id: %S",textid,scriptid,scriptscriptid)
+-- report_fallbacks("used textid: %s, used script id: %s, used scriptscript id: %s",
+-- tostring(textid),tostring(scriptid),tostring(scriptscriptid))
local data = {
textdata = textdata,
scriptdata = scriptdata,
@@ -104,9 +96,6 @@ function fallbacks.apply(target,original)
textindex = textindex,
scriptindex = scriptindex,
scriptscriptindex = scriptscriptindex,
- textid = textid,
- scriptid = scriptid,
- scriptscriptid = scriptscriptid,
characters = characters,
unicode = k,
target = target,
@@ -114,32 +103,24 @@ function fallbacks.apply(target,original)
size = size,
mathsize = mathsize,
}
- target.mathrelation = data
- -- inspect(usedfonts)
+-- inspect(usedfonts)
for k, v in next, virtualcharacters do
if not characters[k] then
local tv = type(v)
- local cd = nil
if tv == "table" then
- cd = v
+ characters[k] = v
elseif tv == "number" then
- cd = characters[v]
+ characters[k] = characters[v]
elseif tv == "function" then
- cd = v(data)
- end
- if cd then
- characters[k] = cd
- else
- -- something else
+ characters[k] = v(data)
end
if trace_fallbacks then
if characters[k] then
- report_fallbacks("extending math font %a with %U",target.properties.fullname,k)
+ report_fallbacks("extending font %a with %U",target.properties.fullname,k)
end
end
end
end
- data.unicode = nil
end
end
@@ -329,177 +310,3 @@ virtualcharacters[0xFE352] = function(data)
end
end
--- we could move the defs from math-act here
-
-local function accent_to_extensible(target,newchr,original,oldchr,height,depth,swap,offset)
- local characters = target.characters
- local addprivate = fonts.helpers.addprivate
- local olddata = characters[oldchr]
- if olddata and not olddata.commands then
- if swap then
- swap = characters[swap]
- height = swap.depth
- depth = 0
- else
- height = height or 0
- depth = depth or 0
- end
- local correction = swap and { "down", (olddata.height or 0) - height } or { "down", olddata.height + (offset or 0)}
- local newdata = {
- commands = { correction, { "slot", 1, oldchr } },
- width = olddata.width,
- height = height,
- depth = depth,
- }
- local glyphdata = newdata
- local nextglyph = olddata.next
- while nextglyph do
- local oldnextdata = characters[nextglyph]
- if oldnextdata then
- local newnextdata = {
- commands = { correction, { "slot", 1, nextglyph } },
- width = oldnextdata.width,
- height = height,
- depth = depth,
- }
- local newnextglyph = addprivate(target,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
- report_fallbacks("error in fallback: no valid next, slot %X",nextglyph)
- break
- 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 = characters[oldglyph]
- if olddata then
- local newdata = {
- commands = { correction, { "slot", 1, oldglyph } },
- width = olddata.width,
- height = height,
- depth = depth,
- }
- hvi.glyph = addprivate(target,formatters["M-H-%H"](oldglyph),newdata)
- else
- report_fallbacks("error in fallback: no valid horiz_variants, slot %X, index %i",oldglyph,i)
- end
- end
- end
- return glyphdata
- else
- return olddata
- end
-end
-
-virtualcharacters[0x203E] = function(data) -- could be FE33E instead
- local target = data.target
- local height, depth = 0, 0
- local mathparameters = target.mathparameters
- if mathparameters then
- height = mathparameters.OverbarVerticalGap
- depth = mathparameters.UnderbarVerticalGap
- else
- height = target.parameters.xheight/4
- depth = height
- end
- return accent_to_extensible(target,0x203E,data.original,0x0305,height,depth)
-end
-
-virtualcharacters[0xFE33E] = virtualcharacters[0x203E] -- convenient
-virtualcharacters[0xFE33F] = virtualcharacters[0x203E] -- convenient
-
-local function smashed(data,unicode,swap,private)
- local target = data.target
- local original = data.original
- local chardata = target.characters[unicode]
- if chardata and chardata.height > target.parameters.xheight then
- return accent_to_extensible(target,private,original,unicode,0,0,swap)
- else
- return original.characters[unicode]
- end
-end
-
-addextra(0xFE3DE, { description="EXTENSIBLE OF 0x03DE", unicodeslot=0xFE3DE, mathextensible = "r", mathstretch = "h" } )
-addextra(0xFE3DC, { description="EXTENSIBLE OF 0x03DC", unicodeslot=0xFE3DC, mathextensible = "r", mathstretch = "h" } )
-addextra(0xFE3B4, { description="EXTENSIBLE OF 0x03B4", unicodeslot=0xFE3B4, mathextensible = "r", mathstretch = "h" } )
-
-virtualcharacters[0xFE3DE] = function(data) return smashed(data,0x23DE,0x23DF,0xFE3DE) end
-virtualcharacters[0xFE3DC] = function(data) return smashed(data,0x23DC,0x23DD,0xFE3DC) end
-virtualcharacters[0xFE3B4] = function(data) return smashed(data,0x23B4,0x23B5,0xFE3B4) end
-
-addextra(0xFE3DF, { description="EXTENSIBLE OF 0x03DF", unicodeslot=0xFE3DF, mathextensible = "r", mathstretch = "h" } )
-addextra(0xFE3DD, { description="EXTENSIBLE OF 0x03DD", unicodeslot=0xFE3DD, mathextensible = "r", mathstretch = "h" } )
-addextra(0xFE3B5, { description="EXTENSIBLE OF 0x03B5", unicodeslot=0xFE3B5, mathextensible = "r", mathstretch = "h" } )
-
-virtualcharacters[0xFE3DF] = function(data) return data.original.characters[0x23DF] end
-virtualcharacters[0xFE3DD] = function(data) return data.original.characters[0x23DD] end
-virtualcharacters[0xFE3B5] = function(data) return data.original.characters[0x23B5] end
-
--- todo: add some more .. numbers might change
-
-addextra(0xFE302, { description="EXTENSIBLE OF 0x0302", unicodeslot=0xFE302, mathstretch = "h" } )
-addextra(0xFE303, { description="EXTENSIBLE OF 0x0303", unicodeslot=0xFE303, mathstretch = "h" } )
-
-local function smashed(data,unicode,private)
- local target = data.target
- local height = target.parameters.xheight / 2
- local c = accent_to_extensible(target,private,data.original,unicode,height,0,nil,-height)
- c.top_accent = nil
- return c
-end
-
-virtualcharacters[0xFE302] = function(data) return smashed(data,0x0302,0xFE302) end
-virtualcharacters[0xFE303] = function(data) return smashed(data,0x0303,0xFE303) end
-
--- another crazy hack .. doesn't work as we define scrscr first .. we now have smaller
--- primes so we have smaller primes for the moment, big ones will become an option
-
-local function smashed(data,unicode,optional)
- local oldchar = data.characters[unicode]
- if oldchar then
- local height = 1.2 * data.target.parameters.xheight
- local newchar = {
- commands = {
- { "down", oldchar.height - height },
- { "char", unicode },
- },
- height = height,
- width = oldchar.width,
- }
- return newchar
- elseif not optional then
- report_fallbacks("missing %U prime in font %a",unicode,data.target.properties.fullname)
- end
-end
-
-addextra(0xFE932, { description="SMASHED PRIME 0x02032", unicodeslot=0xFE932 } )
-addextra(0xFE933, { description="SMASHED PRIME 0x02033", unicodeslot=0xFE933 } )
-addextra(0xFE934, { description="SMASHED PRIME 0x02034", unicodeslot=0xFE934 } )
-addextra(0xFE957, { description="SMASHED PRIME 0x02057", unicodeslot=0xFE957 } )
-
-addextra(0xFE935, { description="SMASHED BACKWARD PRIME 0x02035", unicodeslot=0xFE935 } )
-addextra(0xFE936, { description="SMASHED BACKWARD PRIME 0x02036", unicodeslot=0xFE936 } )
-addextra(0xFE937, { description="SMASHED BACKWARD PRIME 0x02037", unicodeslot=0xFE937 } )
-
-virtualcharacters[0xFE932] = function(data) return smashed(data,0x02032) end
-virtualcharacters[0xFE933] = function(data) return smashed(data,0x02033) end
-virtualcharacters[0xFE934] = function(data) return smashed(data,0x02034) end
-virtualcharacters[0xFE957] = function(data) return smashed(data,0x02057) end
-
-virtualcharacters[0xFE935] = function(data) return smashed(data,0x02035,true) end
-virtualcharacters[0xFE936] = function(data) return smashed(data,0x02036,true) end
-virtualcharacters[0xFE937] = function(data) return smashed(data,0x02037,true) end
-
diff --git a/tex/context/base/math-fen.mkiv b/tex/context/base/math-fen.mkiv
index 94d93e4af..f7edc582e 100644
--- a/tex/context/base/math-fen.mkiv
+++ b/tex/context/base/math-fen.mkiv
@@ -32,15 +32,18 @@
% test $a\fancybracket{\frac{1}{b}}c$ test \par
\installcorenamespace{mathfences}
+\installcorenamespace{mathfencesleft}
+\installcorenamespace{mathfencesmiddle}
+\installcorenamespace{mathfencesright}
\installcommandhandler \??mathfences {mathfence} \??mathfences
\let\setupmathfences\setupmathfence
\setupmathfences
- [\c!left=,
- \c!right=,
- \c!middle=,
+ [\c!left=0x2E,
+ \c!right=0x2E,
+ \c!middle=0x2E,
\c!mathstyle=,
\c!color=,
\c!command=]
@@ -52,61 +55,40 @@
\fi
\to \everydefinemathfence
-% we need the direct use of \Udelimiter because of { etc
-
-\def\math_fenced_left {\edef\p_left{\mathfenceparameter\c!left}%
- \math_fenced_color_push
- \normalleft\ifx\p_left\empty.\else\Udelimiter\plusfour\fam\p_left\relax\fi
- \math_fenced_color_pop}
-\def\math_fenced_middle{\edef\p_middle{\mathfenceparameter\c!middle}%
- \mskip\thinmuskip
- \math_fenced_color_push
- \normalmiddle\ifx\p_middle\empty.\else\Udelimiter\plusfour\fam\p_middle\relax\fi
- \math_fenced_color_pop
- \mskip\thinmuskip}
-\def\math_fenced_right {\edef\p_right{\mathfenceparameter\c!right}%
- \math_fenced_color_push
- \normalright\ifx\p_right\empty.\else\Udelimiter\plusfive\fam\p_right\relax\fi
- \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
+\def\math_fenced_left {\normalleft \utfchar{\mathfenceparameter\c!left }} % no Uchar here
+\def\math_fenced_middle{\normalmiddle\utfchar{\mathfenceparameter\c!middle}} % no Uchar here
+\def\math_fenced_right {\normalright \utfchar{\mathfenceparameter\c!right }} % no Uchar here
\let\fence \relax
\let\fenced\relax
-\newcount\c_math_fenced_nesting
-
-\unexpanded\def\math_fenced_fenced_start#1%
- {\advance\c_math_fenced_nesting\plusone
- \begingroup
+\unexpanded\def\math_fenced_fenced[#1]%
+ {\begingroup
\edef\currentmathfence{#1}%
\startusemathstyleparameter\mathfenceparameter
\let\fence\math_fenced_middle
\edef\p_math_fenced_color{\mathfenceparameter\c!color}%
\ifx\p_math_fenced_color\empty
- \let\math_fenced_color_push\donothing
- \let\math_fenced_color_pop \donothing
+ \expandafter\math_fenced_normal
\else
- \let\math_fenced_color_push\math_fenced_color_do_push
- \let\math_fenced_color_pop \math_fenced_color_do_pop
- \fi
- \math_fenced_left}
+ \expandafter\math_fenced_colored
+ \fi}
-\unexpanded\def\math_fenced_fenced_stop#1%
- {\edef\currentmathfence{#1}%
+\def\math_fenced_normal#1%
+ {\math_fenced_left
+ #1%
\math_fenced_right
\stopusemathstyleparameter
- \endgroup
- \advance\c_math_fenced_nesting\minusone}
+ \endgroup}
-\unexpanded\def\math_fenced_fenced[#1]#2%
- {\math_fenced_fenced_start{#1}%
- #2%
+\def\math_fenced_colored#1%
+ {\pushcolor[\p_math_fenced_color]%
+ \math_fenced_left
+ \popcolor
+ #1%
+ \pushcolor[\p_math_fenced_color]%
\math_fenced_right
+ \popcolor
\stopusemathstyleparameter
\endgroup}
@@ -114,353 +96,13 @@
\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 [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 [mirrorednothing] [mirorred]
-
-%D A bonus:
-
-\unexpanded\def\Lparent {\math_fenced_fenced_start{parenthesis}} \unexpanded\def\Rparent {\math_fenced_fenced_stop{parenthesis}}
-\unexpanded\def\Lbracket {\math_fenced_fenced_start{bracket}} \unexpanded\def\Rbracket {\math_fenced_fenced_stop{bracket}}
-\unexpanded\def\Lbrace {\math_fenced_fenced_start{brace}} \unexpanded\def\Rbrace {\math_fenced_fenced_stop{brace}}
-\unexpanded\def\Langle {\math_fenced_fenced_start{angle}} \unexpanded\def\Rangle {\math_fenced_fenced_stop{angle}}
-\unexpanded\def\Ldoubleangle {\math_fenced_fenced_start{doubleangle}} \unexpanded\def\Rdoubleangle {\math_fenced_fenced_stop{doubleangle}}
-\unexpanded\def\Lbar {\math_fenced_fenced_start{bar}} \unexpanded\def\Rbar {\math_fenced_fenced_stop{bar}}
-\unexpanded\def\Ldoublebar {\math_fenced_fenced_start{doublebar}} \unexpanded\def\Rdoublebar {\math_fenced_fenced_stop{doublebar}}
-\unexpanded\def\Ltriplebar {\math_fenced_fenced_start{triplebar}} \unexpanded\def\Rtriplebar {\math_fenced_fenced_stop{triplebar}}
-\unexpanded\def\Lsolidus {\math_fenced_fenced_start{solidus}} \unexpanded\def\Rsolidus {\math_fenced_fenced_stop{solidus}}
-\unexpanded\def\Lnothing {\math_fenced_fenced_start{nothing}} \unexpanded\def\Rnothing {\math_fenced_fenced_stop{nothing}}
-
-\unexpanded\def\Lparentmirrored {\math_fenced_fenced_stop{mirroredparenthesis}} \unexpanded\def\Rparentmirrored {\math_fenced_fenced_start{mirroredparenthesis}}
-\unexpanded\def\Lbracketmirrored {\math_fenced_fenced_stop{mirroredbracket}} \unexpanded\def\Rbracketmirrored {\math_fenced_fenced_start{mirroredbracket}}
-\unexpanded\def\Lbracemirrored {\math_fenced_fenced_stop{mirroredbrace}} \unexpanded\def\Rbracemirrored {\math_fenced_fenced_start{mirroredbrace}}
-\unexpanded\def\Langlemirrored {\math_fenced_fenced_stop{mirroredangle}} \unexpanded\def\Ranglemirrored {\math_fenced_fenced_start{mirroredangle}}
-\unexpanded\def\Ldoubleanglemirrored {\math_fenced_fenced_stop{mirroreddoubleangle}} \unexpanded\def\Rdoubleanglemirrored {\math_fenced_fenced_start{mirroreddoubleangle}}
-\unexpanded\def\Lbarmirrored {\math_fenced_fenced_stop{mirroredbar}} \unexpanded\def\Rbarmirrored {\math_fenced_fenced_start{mirroredbar}}
-\unexpanded\def\Ldoublebarmirrored {\math_fenced_fenced_stop{mirroreddoublebar}} \unexpanded\def\Rdoublebarmirrored {\math_fenced_fenced_start{mirroreddoublebar}}
-\unexpanded\def\Ltriplebarmirrored {\math_fenced_fenced_stop{mirroredtriplebar}} \unexpanded\def\Rtriplebarmirrored {\math_fenced_fenced_start{mirroredtriplebar}}
-\unexpanded\def\Lsolidusmirrored {\math_fenced_fenced_stop{mirroredsolidus}} \unexpanded\def\Rsolidusmirrored {\math_fenced_fenced_start{mirroredsolidus}}
-\unexpanded\def\Lnothingmirrored {\math_fenced_fenced_stop{mirrorednothing}} \unexpanded\def\Rnothingmirrored {\math_fenced_fenced_start{mirrorednothing}}
-
-%D And another one:
-
-% \setupmathfences[color=darkgreen]
-%
-% \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
-
-\installcorenamespace{mathleft}
-\installcorenamespace{mathright}
-\installcorenamespace{mathmiddle}
-
-\unexpanded\def\left {\afterassignment\math_left \let\nexttoken}
-\unexpanded\def\right {\afterassignment\math_right \let\nexttoken}
-\unexpanded\def\middle{\afterassignment\math_middle\let\nexttoken}
-
-\newconditional\c_math_fenced_done
-\newconditional\c_math_fenced_unknown \settrue\c_math_fenced_unknown
-
-\def\math_left
- {\settrue\c_math_fenced_done
- \edef\m_math_left{\meaning\nexttoken}%
- \csname\??mathleft\ifcsname\??mathleft\m_math_left\endcsname\m_math_left\else\s!unknown\fi\endcsname}
-
-\def\math_right
- {\settrue\c_math_fenced_done
- \edef\m_math_right{\meaning\nexttoken}%
- \csname\??mathright\ifcsname\??mathright\m_math_right\endcsname\m_math_right\else\s!unknown\fi\endcsname}
-
-\def\math_middle
- {\settrue\c_math_fenced_done
- \edef\m_math_middle{\meaning\nexttoken}%
- \csname\??mathmiddle\ifcsname\??mathmiddle\m_math_middle\endcsname\m_math_middle\else\s!unknown\fi\endcsname}
-
-\setvalue{\??mathleft \s!unknown}{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalleft \nexttoken\fi}
-\setvalue{\??mathright \s!unknown}{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalright \nexttoken\fi}
-\setvalue{\??mathmiddle\s!unknown}{\setfalse\c_math_fenced_done\ifconditional\c_math_fenced_unknown\normalmiddle\nexttoken\fi}
-
-\unexpanded\def\installmathfencepair#1#2#3#4%
- {\expandafter\let\csname\??mathleft \meaning#1\endcsname#2%
- \expandafter\let\csname\??mathright\meaning#3\endcsname#4}
-
-\expandafter\let\csname\??mathleft \meaning [\endcsname\Lbracket
-\expandafter\let\csname\??mathleft \meaning (\endcsname\Lparent
-\expandafter\let\csname\??mathleft \meaning <\endcsname\Langle
-\expandafter\let\csname\??mathleft \meaning ⟨\endcsname\Langle
-\expandafter\let\csname\??mathleft \meaning ⟪\endcsname\Ldoubleangle
-\expandafter\let\csname\??mathleft \meaning {\endcsname\Lbrace
-\expandafter\let\csname\??mathleft \meaning |\endcsname\Lbar
-\expandafter\let\csname\??mathleft \meaning ‖\endcsname\Ldoublebar
-\expandafter\let\csname\??mathleft \meaning ⦀\endcsname\Ltriplebar
-\expandafter\let\csname\??mathleft \meaning /\endcsname\Lsolidus
-\expandafter\let\csname\??mathleft \meaning .\endcsname\Lnothing
-
-\expandafter\let\csname\??mathright\meaning ]\endcsname\Rbracket
-\expandafter\let\csname\??mathright\meaning )\endcsname\Rparent
-\expandafter\let\csname\??mathright\meaning >\endcsname\Rangle
-\expandafter\let\csname\??mathright\meaning ⟩\endcsname\Rangle
-\expandafter\let\csname\??mathright\meaning ⟫\endcsname\Rdoubleangle
-\expandafter\let\csname\??mathright\meaning }\endcsname\Rbrace
-\expandafter\let\csname\??mathright\meaning |\endcsname\Rbar
-\expandafter\let\csname\??mathright\meaning ⦀\endcsname\Rtriplebar
-\expandafter\let\csname\??mathright\meaning /\endcsname\Rsolidus
-\expandafter\let\csname\??mathright\meaning .\endcsname\Rnothing
-
-\expandafter\let\csname\??mathright\meaning [\endcsname\Lbracketmirrored
-\expandafter\let\csname\??mathright\meaning (\endcsname\Lparentmirrored
-\expandafter\let\csname\??mathright\meaning <\endcsname\Langlemirrored
-\expandafter\let\csname\??mathright\meaning ⟨\endcsname\Langlemirrored
-\expandafter\let\csname\??mathright\meaning ⟪\endcsname\Ldoubleanglemirrored
-\expandafter\let\csname\??mathright\meaning {\endcsname\Lbracemirrored
-%expandafter\let\csname\??mathright\meaning |\endcsname\Lbarmirrored
-%expandafter\let\csname\??mathright\meaning ‖\endcsname\Ldoublebarmirrored
-%expandafter\let\csname\??mathright\meaning ⦀\endcsname\Ltriplebarmirrored
-\expandafter\let\csname\??mathright\meaning /\endcsname\Lsolidusmirrored
-\expandafter\let\csname\??mathright\meaning .\endcsname\Lnothingmirrored
-
-\expandafter\let\csname\??mathleft \meaning ]\endcsname\Rbracketmirrored
-\expandafter\let\csname\??mathleft \meaning )\endcsname\Rparentmirrored
-\expandafter\let\csname\??mathleft \meaning >\endcsname\Ranglemirrored
-\expandafter\let\csname\??mathleft \meaning ⟩\endcsname\Ranglemirrored
-\expandafter\let\csname\??mathleft \meaning ⟫\endcsname\Rdoubleanglemirrored
-\expandafter\let\csname\??mathleft \meaning }\endcsname\Rbracemirrored
-%expandafter\let\csname\??mathleft \meaning |\endcsname\Rbarmirrored
-%expandafter\let\csname\??mathleft \meaning ‖\endcsname\Rdoublebarmirrored
-%expandafter\let\csname\??mathleft \meaning ⦀\endcsname\Rtriplebarmirrored
-\expandafter\let\csname\??mathleft \meaning /\endcsname\Rsolidusmirrored
-\expandafter\let\csname\??mathleft \meaning .\endcsname\Rnothingmirrored
-
-% todo paren parent
-
-\let\lbrack\lbracket
-\let\rbrack\rbracket
-
-\installmathfencepair \lbrace \Lbrace \rbrace \Rbrace
-\installmathfencepair \lbracket \Lbracket \rbracket \Rbracket
-\installmathfencepair \lparen \Lparen \rparen \Rparen
-\installmathfencepair \lparent \Lparent \rparent \Rparent
-\installmathfencepair \langle \Langle \rangle \Rangle
-%installmathfencepair \lrangle \Ldoubleangle \rrangle \Rdoubleangle
-%installmathfencepair \lbar \Lbar \rbar \Rbar
-\installmathfencepair \vert \Lbar \vert \Rbar
-\installmathfencepair \solidus \Lsolidus \solidus \Rsolidus
-
-\unexpanded\def\{{\mathortext\lbrace \letterleftbrace } % or maybe a chardef
-\unexpanded\def\}{\mathortext\rbrace \letterrightbrace } % or maybe a chardef
-\unexpanded\def\[{\mathortext\lbracket\letterleftbracket } % or maybe a chardef
-\unexpanded\def\]{\mathortext\rbracket\letterrightbracket} % or maybe a chardef
-\unexpanded\def\({\mathortext\lparent \letterleftparent } % or maybe a chardef
-\unexpanded\def\){\mathortext\rparent \letterrightparent } % or maybe a chardef
-\unexpanded\def\|{\mathortext\vert \letterbar } % or maybe a chardef
-%unexpanded\def\/{\mathortext\solidus \letterslash } % or maybe a chardef
-
-\installmathfencepair \{ \Lbrace \} \Rbrace
-\installmathfencepair \[ \Lbracket \] \Rbracket
-\installmathfencepair \( \Lparent \) \Rparent
-\installmathfencepair \< \Langle \> \Rangle
-\installmathfencepair \| \Lbar \| \Rbar
-
-%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 \plusone
-\setnewconstant\bigmathdelimitervariant\plusthree
-
-\unexpanded\def\plainbigdelimiters % traditional method
- {\bigmathdelimitermethod\plustwo}
-
-\plainbigdelimiters % is default for the moment but not so nice
-
-% \setconstant\bigmathdelimitermethod\plusone
-
-\installcorenamespace{mathbig}
-
-\unexpanded\def\choosemathbig#1#2% so we accept \big{||} as well
- {{\hbox\bgroup
- \startimath
- \ifcase\bigmathdelimitermethod
- \math_fenced_step#2\relax
- \or
- \attribute\mathsizeattribute\numexpr\bigmathdelimitervariant*\plushundred+#1\relax
- \math_fenced_step#2\relax
- \else
- \math_fenced_step#2{\vbox to\getvalue{\??mathbig\number#1}\bodyfontsize{}}%
- \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}
-
-\unexpanded\def\mathdelimiterstep#1#2%
- {\begingroup
- \attribute\mathsizeattribute\numexpr\plushundred+#1\relax
- \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 [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 [parenthesis] [\c!left=0x28,\c!right=0x29]
+\definemathfence [bracket] [\c!left=0x5B,\c!right=0x5D]
+\definemathfence [braces] [\c!left=0x7B,\c!right=0x7D]
+\definemathfence [bar] [\c!left=0x7C,\c!right=0x7C]
+\definemathfence [doublebar] [\c!left=0x2016,\c!right=0x2016]
+\definemathfence [angle] [\c!left=0x3C,\c!right=0x3E]
%definemathfence [fancybracket] [bracket] [command=yes,color=red]
-% experimental accents:
-%
-% \definemathoverextensible [top] [hoed] ["FE302]
-% \definemathoverextensible [top] [slang] ["FE303]
-
-%D This is needed for mathml (used in mrow, so it gets reset):
-
-\let\math_fences_saved_left \left
-\let\math_fences_saved_middle\middle
-\let\math_fences_saved_right \right
-
-% \def\math_fences_traced#1{\ruledhbox{\ttx#1\low{\the\c_math_fenced_nesting}}}
-
-\unexpanded\def\math_fences_checked_left
- {%\math_fences_traced L%
- \math_fences_saved_left}
-
-\unexpanded\def\math_fences_checked_middle
- {%\math_fences_traced M%
- \ifcase\c_math_fenced_nesting
- \expandafter\math_fences_saved_middle
- \else
- \expandafter\firstofoneargument
- \fi}
-
-\unexpanded\def\math_fences_checked_right
- {%\math_fences_traced R%
- \ifcase\c_math_fenced_nesting
- \expandafter\firstofoneargument
- \else
- \expandafter\math_fences_saved_right
- \fi}
-
-\newconditional\c_math_checked_done % only bars
-
-\unexpanded\def\math_fences_checked_left_or_right
- {%\math_fences_traced B%
- \ifcase\c_math_fenced_nesting
- \settrue\c_math_checked_done
- \expandafter\math_fences_saved_left
- \else\ifconditional\c_math_checked_done
- \setfalse\c_math_checked_done
- \doubleexpandafter\math_fences_saved_right
- \else
- \doubleexpandafter\math_fences_saved_middle
- \fi\fi}
-
-\unexpanded\def\math_fences_checked_start
- {\c_math_fenced_nesting\zerocount}
-
-\unexpanded\def\math_fences_checked_stop
- {\ifcase\c_math_fenced_nesting\else
- \right.\relax % error, todo: nil spacing
- \expandafter\math_fences_checked_stop
- \fi}
-
-\unexpanded\def\startcheckedfences
- {\begingroup
- \let\left \math_fences_checked_left
- \let\middle\math_fences_checked_middle
- \let\right \math_fences_checked_right
- \math_fences_checked_start}
-
-\unexpanded\def\stopcheckedfences
- {\math_fences_checked_stop
- \endgroup}
-
-\let\leftorright\math_fences_checked_left_or_right % for bars
-
-%D The next characters were used for constructing nicer extensibles but
-%D nowadays we have real characters.
-
-\Umathchardef\braceld=0 \defaultmathfamily "FF07A
-\Umathchardef\bracerd=0 \defaultmathfamily "FF07B
-\Umathchardef\bracelu=0 \defaultmathfamily "FF07C
-\Umathchardef\braceru=0 \defaultmathfamily "FF07D
-
\protect
diff --git a/tex/context/base/math-frc.mkiv b/tex/context/base/math-frc.mkiv
index 65fa30942..e11e79e82 100644
--- a/tex/context/base/math-frc.mkiv
+++ b/tex/context/base/math-frc.mkiv
@@ -102,7 +102,6 @@
\setupmathfractions
[\c!mathstyle=,
\c!alternative=\v!inner,
- \c!margin=\zeropoint,
\c!rulethickness=.25\exheight,
\c!left=0x2E,
\c!right=0x2E,
@@ -112,12 +111,9 @@
\setuevalue{\currentmathfraction}{\math_frac{\currentmathfraction}}%
\to \everydefinemathfraction
-\newdimen\d_math_fraction_margin
-
\unexpanded\def\math_frac#1%
{\begingroup
\edef\currentmathfraction{#1}%
- \d_math_fraction_margin\mathfractionparameter\c!margin
\edef\p_math_fractions_color{\mathfractionparameter\c!color}%
\ifx\p_math_fractions_color\empty
\expandafter\math_frac_normal
@@ -143,58 +139,19 @@
\number\dimexpr\mathfractionparameter\c!rulethickness%
)}}
-% 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.
-
-\setvalue{\??mathfractionalternative\v!inner}%
- {\ifcase\d_math_fraction_margin
- \expandafter\math_fraction_inner_normal
- \else
- \expandafter\math_fraction_inner_margin
- \fi}
-
-\def\math_fraction_inner_normal#1#2%
+\setvalue{\??mathfractionalternative\v!inner}#1#2%
{\Ustack{%
{\usemathstyleparameter\mathfractionparameter{#1}}% we should store this one
\math_frac_command
{\usemathstyleparameter\mathfractionparameter{#2}}% and reuse it here
}\endgroup}
-\def\math_fraction_inner_margin#1#2%
- {\Ustack{%
- {\kern\d_math_fraction_margin
- \usemathstyleparameter\mathfractionparameter{#1}% we should store this one
- \kern\d_math_fraction_margin}%
- \math_frac_command
- {\kern\d_math_fraction_margin
- \usemathstyleparameter\mathfractionparameter{#2}% and reuse it here
- \kern\d_math_fraction_margin}%
- }\endgroup}
-
-\setvalue{\??mathfractionalternative\v!outer}%
- {\ifcase\d_math_fraction_margin
- \expandafter\math_fraction_outer_normal
- \else
- \expandafter\math_fraction_outer_margin
- \fi}
-
-\def\math_fraction_outer_normal#1#2%
+\setvalue{\??mathfractionalternative\v!outer}#1#2%
{\Ustack{%
\usemathstyleparameter\mathfractionparameter
{{#1}\math_frac_command{#2}}%
}\endgroup}
-\def\math_fraction_outer_margin#1#2%
- {\Ustack{%
- \usemathstyleparameter\mathfractionparameter
- {{\kern\d_math_fraction_margin#1\kern\d_math_fraction_margin}%
- \math_frac_command
- {\kern\d_math_fraction_margin#2\kern\d_math_fraction_margin}}%
- }\endgroup}
-
\definemathfraction[frac][\c!mathstyle=]
\unexpanded\def\xfrac {\begingroup\let\xfrac\xxfrac\math_frac_alternative\scriptstyle}
diff --git a/tex/context/base/math-ini.lua b/tex/context/base/math-ini.lua
index 6be06e634..7ba1d4514 100644
--- a/tex/context/base/math-ini.lua
+++ b/tex/context/base/math-ini.lua
@@ -16,18 +16,19 @@ if not modules then modules = { } end modules ['math-ini'] = {
-- then we also have to set the other characters (only a subset done now)
local formatters, find = string.formatters, string.find
-local utfchar, utfbyte, utflength = utf.char, utf.byte, utf.length
+local utfchar, utfbyte = utf.char, utf.byte
+local setmathcode, setdelcode = tex.setmathcode, tex.setdelcode
+local settexattribute = tex.setattribute
local floor = math.floor
-local context = context
-local commands = commands
+local context = context
-local contextsprint = context.sprint
-local contextfprint = context.fprint -- a bit inefficient
+local contextsprint = context.sprint
+local contextfprint = context.fprint -- a bit inefficient
-local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
+local trace_defining = false trackers.register("math.defining", function(v) trace_defining = v end)
-local report_math = logs.reporter("mathematics","initializing")
+local report_math = logs.reporter("mathematics","initializing")
mathematics = mathematics or { }
local mathematics = mathematics
@@ -39,10 +40,6 @@ local unsetvalue = attributes.unsetvalue
local allocate = utilities.storage.allocate
local chardata = characters.data
-local texsetattribute = tex.setattribute
-local setmathcode = tex.setmathcode
-local setdelcode = tex.setdelcode
-
local families = allocate {
mr = 0,
mb = 1,
@@ -90,7 +87,6 @@ local classes = allocate {
large = 1, -- op
variable = 7, -- alphabetic
number = 7, -- alphabetic
- root = 16, -- a private one
}
local open_class = 4
@@ -155,10 +151,6 @@ local function radical(family,slot)
return formatters['\\Uradical "%X "%X '](family,slot)
end
-local function root(family,slot)
- return formatters['\\Uroot "%X "%X '](family,slot)
-end
-
local function mathchardef(name,class,family,slot)
return formatters['\\Umathchardef\\%s "%X "%X "%X '](name,class,family,slot)
end
@@ -199,42 +191,29 @@ 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 ]] ]
-
local setmathsymbol = function(name,class,family,slot) -- hex is nicer for tracing
if class == classes.accent then
- contextsprint(f_accent(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ](name,family,slot))
elseif class == classes.topaccent then
- contextsprint(f_topaccent(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Umathaccent 0 "%X "%X }]] ](name,family,slot))
elseif class == classes.botaccent then
- contextsprint(f_botaccent(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Umathbotaccent 0 "%X "%X }]] ](name,family,slot))
elseif class == classes.over then
- contextsprint(f_over(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Udelimiterover "%X "%X }]] ](name,family,slot))
elseif class == classes.under then
- contextsprint(f_under(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Udelimiterunder "%X "%X }]] ](name,family,slot))
elseif class == open_class or class == close_class or class == middle_class then
setdelcode("global",slot,{family,slot,0,0})
- contextsprint(f_fence(name,class,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Udelimiter "%X "%X "%X }]] ](name,class,family,slot))
elseif class == classes.delimiter then
setdelcode("global",slot,{family,slot,0,0})
- contextsprint(f_delimiter(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Udelimiter 0 "%X "%X }]] ](name,family,slot))
elseif class == classes.radical then
- contextsprint(f_radical(name,family,slot))
- elseif class == classes.root then
- contextsprint(f_root(name,family,slot))
+ contextsprint(formatters[ [[\ugdef\%s{\Uradical "%X "%X }]] ](name,family,slot))
else
-- beware, open/close and other specials should not end up here
- contextsprint(f_char(name,class,family,slot))
+ -- contextsprint(formatters[ [[\ugdef\%s{\Umathchar "%X "%X "%X }]],name,class,family,slot))
+ contextsprint(formatters[ [[\Umathchardef\%s "%X "%X "%X ]] ](name,class,family,slot))
end
end
@@ -334,55 +313,30 @@ function mathematics.define(family)
end
-- needed for mathml analysis
--- string with # > 1 are invalid
--- we could cache
-
-local lpegmatch = lpeg.match
-
-local utf8byte = lpeg.patterns.utf8byte * lpeg.P(-1)
-
--- function somechar(c)
--- local b = lpegmatch(utf8byte,c)
--- return b and chardata[b]
--- end
-
-local somechar = { }
-
-table.setmetatableindex(somechar,function(t,k)
- local b = lpegmatch(utf8byte,k)
- local v = b and chardata[b] or false
- t[k] = v
- return v
-end)
+-- we could cache
local function utfmathclass(chr, default)
- local cd = somechar[chr]
+ local cd = chardata[utfbyte(chr)]
return cd and cd.mathclass or default or "unknown"
end
-local function utfmathaccent(chr,default,asked1,asked2)
- local cd = somechar[chr]
+local function utfmathaccent(chr,default,asked)
+ local cd = chardata[utfbyte(chr)]
if not cd then
return default or false
end
- if asked1 and asked1 ~= "" then
+ if asked then
local mc = cd.mathclass
- if mc and (mc == asked1 or mc == asked2) then
+ if mc and mc == asked then
return true
end
local ms = cd.mathspec
- if not ms then
- local mp = cd.mathparent
- if mp then
- ms = chardata[mp].mathspec
- end
- end
if ms then
for i=1,#ms do
local msi = ms[i]
local mc = msi.class
- if mc and (mc == asked1 or mc == asked2) then
+ if mc and mc == asked then
return true
end
end
@@ -406,38 +360,32 @@ local function utfmathaccent(chr,default,asked1,asked2)
return default or false
end
-local function utfmathstretch(chr,default) -- "h", "v", "b", ""
- local cd = somechar[chr]
+local function utfmathstretch(chr, default) -- "h", "v", "b", ""
+ local cd = chardata[utfbyte(chr)]
return cd and cd.mathstretch or default or ""
end
-local function utfmathcommand(chr,default,asked1,asked2)
- local cd = somechar[chr]
+local function utfmathcommand(chr,default,asked)
+-- local cd = chardata[utfbyte(chr)]
+-- local cmd = cd and cd.mathname
+-- return cmd or default or ""
+ local cd = chardata[utfbyte(chr)]
if not cd then
return default or ""
end
- if asked1 then
+ if asked then
local mn = cd.mathname
local mc = cd.mathclass
- if mn and mc and (mc == asked1 or mc == asked2) then
+ if mn and mc and mc == asked then
return mn
end
local ms = cd.mathspec
- if not ms then
- local mp = cd.mathparent
- if mp then
- ms = chardata[mp].mathspec
- end
- end
if ms then
for i=1,#ms do
local msi = ms[i]
local mn = msi.name
- if mn then
- local mc = msi.class
- if mc == asked1 or mc == asked2 then
- return mn
- end
+ if mn and msi.class == asked then
+ return mn
end
end
end
@@ -461,7 +409,7 @@ local function utfmathcommand(chr,default,asked1,asked2)
end
local function utfmathfiller(chr, default)
- local cd = somechar[chr]
+ local cd = chardata[utfbyte(chr)]
local cmd = cd and (cd.mathfiller or cd.mathname)
return cmd or default or ""
end
@@ -482,31 +430,17 @@ function commands.doifelseutfmathaccent(chr,asked)
commands.doifelse(utfmathaccent(chr,nil,asked))
end
-function commands.utfmathcommandabove(asked) context(utfmathcommand(asked,nil,"topaccent","over" )) end
-function commands.utfmathcommandbelow(asked) context(utfmathcommand(asked,nil,"botaccent","under")) end
-
-function commands.doifelseutfmathabove(chr) commands.doifelse(utfmathaccent(chr,nil,"topaccent","over" )) end
-function commands.doifelseutfmathbelow(chr) commands.doifelse(utfmathaccent(chr,nil,"botaccent","under")) end
-
-- helpers
---
--- 1: step 1
--- 2: step 2
--- 3: htdp * 1.33^n
--- 4: size * 1.33^n
-function mathematics.big(tfmdata,unicode,n,method)
+function mathematics.big(tfmdata,unicode,n)
local t = tfmdata.characters
local c = t[unicode]
- if c and n > 0 then
+ if c then
local vv = c.vert_variants or c.next and t[c.next].vert_variants
if vv then
local vvn = vv[n]
return vvn and vvn.glyph or vv[#vv].glyph or unicode
- elseif method == 1 or method == 2 then
- if method == 2 then -- large steps
- n = n * 2
- end
+ else
local next = c.next
while next do
if n <= 1 then
@@ -521,27 +455,6 @@ function mathematics.big(tfmdata,unicode,n,method)
end
end
end
- else
- local size = 1.33^n
- if method == 4 then
- size = tfmdata.parameters.size * size
- else -- if method == 3 then
- size = (c.height + c.depth) * size
- end
- local next = c.next
- while next do
- local cn = t[next]
- if (cn.height + cn.depth) >= size then
- return next
- else
- local tn = cn.next
- if tn then
- next = tn
- else
- return next
- end
- end
- end
end
end
return unicode
@@ -578,10 +491,10 @@ end
--
-- function commands.taggedmathfunction(tag,label)
-- if label then
--- texsetattribute(a_mathcategory,registercategory(1,tag,tag))
+-- settexattribute(a_mathcategory,registercategory(1,tag,tag))
-- context.mathlabeltext(tag)
-- else
--- texsetattribute(a_mathcategory,1)
+-- settexattribute(a_mathcategory,1)
-- context(tag)
-- end
-- end
@@ -604,13 +517,13 @@ function commands.taggedmathfunction(tag,label,apply)
noffunctions = noffunctions + 1
functions[noffunctions] = tag
functions[tag] = noffunctions
- texsetattribute(a_mathcategory,noffunctions + delta)
+ settexattribute(a_mathcategory,noffunctions + delta)
else
- texsetattribute(a_mathcategory,n + delta)
+ settexattribute(a_mathcategory,n + delta)
end
context.mathlabeltext(tag)
else
- texsetattribute(a_mathcategory,1000 + delta)
+ settexattribute(a_mathcategory,1000 + delta)
context(tag)
end
end
@@ -629,6 +542,6 @@ function commands.resetmathattributes()
end
end
for i=1,#list do
- texsetattribute(list[i],unsetvalue)
+ settexattribute(list[i],unsetvalue)
end
end
diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv
index f2327c22c..81ec339d6 100644
--- a/tex/context/base/math-ini.mkiv
+++ b/tex/context/base/math-ini.mkiv
@@ -44,14 +44,6 @@
\registerctxluafile{math-noa}{1.001}
\registerctxluafile{math-tag}{1.001}
\registerctxluafile{math-fbk}{1.001}
-\registerctxluafile{math-dir}{1.001}
-
-%D A few compatibility helpers:
-
-\def\Umathbotaccent{\Umathaccent \s!bottom }
-\def\Umathaccents {\Umathaccent \s!both }
-
-%D The attributes that we will use:
\definesystemattribute[mathalphabet] [public]
\definesystemattribute[mathsize] [public]
@@ -62,7 +54,6 @@
\definesystemattribute[mathcategory] [public]
\definesystemattribute[mathmode] [public]
\definesystemattribute[mathitalics] [public]
-\definesystemattribute[mathbidi] [public]
\definesystemattribute[displaymath] [public]
@@ -286,15 +277,9 @@
\def\utfmathclassfiltered #1#2{\ctxcommand{utfmathclass (\!!bs#1\!!es,nil,"#2")}}
\def\utfmathcommandfiltered#1#2{\ctxcommand{utfmathcommand(\!!bs#1\!!es,nil,"#2")}}
-\def\utfmathcommandabove#1{\ctxcommand{utfmathcommandabove(\!!bs#1\!!es)}}
-\def\utfmathcommandbelow#1{\ctxcommand{utfmathcommandbelow(\!!bs#1\!!es)}}
-
\unexpanded\def\doifelseutfmathaccent #1{\ctxcommand{doifelseutfmathaccent(\!!bs#1\!!es)}}
\unexpanded\def\doifelseutfmathaccentfiltered#1#2{\ctxcommand{doifelseutfmathaccent(\!!bs#1\!!es,"#2")}}
-\unexpanded\def\doifelseutfmathabove #1{\ctxcommand{doifelseutfmathabove(\!!bs#1\!!es)}}
-\unexpanded\def\doifelseutfmathbelow #1{\ctxcommand{doifelseutfmathbelow(\!!bs#1\!!es)}}
-
%D Not used that much:
\installcorenamespace{mathcodecommand}
@@ -364,17 +349,6 @@
\unexpanded\def\mathcommand#1%
{\csname\??mathcommand#1\endcsname}
-%D Let's define a few comands here:
-
-\definemathcommand [mathstrut] {\vphantom{(}}
-%definemathcommand [joinrel] {\mathrel{\mkern-3mu}}
-\definemathcommand [joinrel] [rel] {\mkern-3mu}
-
-%D We could have a arg variant \unknown\ but not now.
-
-\unexpanded\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
-\unexpanded\def\stackrel #1#2{\mathrel{\mathop{#2}\limits^{#1}}}
-
%D Moved from font-ini.mkiv:
%D
%D \macros
@@ -414,17 +388,6 @@
{\ifdefined\normalhbox\else\let\normalhbox\hbox\fi % ?
\let\hbox\mbox}
-\unexpanded\def\snappedmath#1% sort of \struttedbox
- {\dontleavehmode
- \begingroup
- \setbox\scratchbox\hbox\bgroup
- \startimath#1\stopimath
- \egroup
- \ht\scratchbox\strutht
- \dp\scratchbox\strutht
- \box\scratchbox
- \endgroup}
-
%D The next hack is needed needed for sine, cosine etc.
\let\mathfunction\firstofoneunexpanded
@@ -531,6 +494,10 @@
%D \tt test $\sin{(x^{\sin(x^{\sin(x)})})}$ test
%D \stoptyping
+%D Some goodies:
+
+\unexpanded\def\Angstrom{\nomathematics{\Aring}}
+
%D \macros
%D {nonknuthmode, donknuthmode}
%D
@@ -564,13 +531,12 @@
\def\activatemathcharacters
{\the\activatedmathcharacters}
-% beware, not runtime, so has to happen at format generation
+% \setnewconstant\primeasciicode 39 % '
\activatemathcharacter\circumflexasciicode
\activatemathcharacter\underscoreasciicode
\activatemathcharacter\ampersandasciicode
-
-% \activatemathcharacter\primeasciicode
+\activatemathcharacter\primeasciicode
% not used:
%
@@ -635,57 +601,57 @@
\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
-%
-% \unexpanded\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
+\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
+
+\unexpanded\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
\bgroup
@@ -706,8 +672,8 @@
\newconditional \knuthmode
-\let\nonknuthmode\relax % no longer needed in MkIV
-\let\donknuthmode\relax % no longer needed in MkIV
+\let\nonknuthmode\relax
+\let\donknuthmode\relax
% \def\nonknuthmode
% {\pushcatcodetable
@@ -818,34 +784,7 @@
\setupmathematics
[\c!compact=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
+%D Arabic:
\newconditional\c_math_right_to_left
@@ -858,28 +797,9 @@
\appendtoks
\math_basics_synchronize_direction
-%to \everymathematics % 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)
-\to \everyswitchmathematics
-
-% experimental (needed for an article)
-
-\installcorenamespace {mathbidi}
-
-\newcount\c_math_bidi
-
-\setvalue{\??mathbidi\v!no }{\ctxcommand{setmathdirection(0)}\c_math_bidi\attributeunsetvalue}
-\setvalue{\??mathbidi\v!yes}{\ctxcommand{setmathdirection(1)}\c_math_bidi\plusone}
-
-\appendtoks
- \edef\p_bidi{\mathematicsparameter\c!bidi}%
- \csname\??mathbidi\ifcsname\??mathbidi\p_bidi\endcsname\p_bidi\else\v!no\fi\endcsname
-\to \everysetupmathematics
-
-\appendtoks
- \attribute\mathbidiattribute\ifconditional\c_math_right_to_left\c_math_bidi\else\attributeunsetvalue\fi
+%to \everymathematics % comes too late and I'm not in the mood for a mixed mode kludge now
\to \everyswitchmathematics
-
%D Delayed: greek.
%D
%D \starttyping
@@ -1088,9 +1008,6 @@
% \global\mathcode\c_math_period\c_math_special
% \to \everyjob
-% \activatemathcharacter\c_math_comma
-% \activatemathcharacter\c_math_period
-
\appendtoks
\mathcode\c_math_comma \c_math_special
\mathcode\c_math_period\c_math_special
@@ -1722,7 +1639,7 @@
%
% \def\displ@y
% {\global\dt@ptrue
-% \math_openup\displayopenupvalue % was \openup\jot
+% \openup\displayopenupvalue % was \openup\jot
% \everycr
% {\noalign
% {\ifdt@p
@@ -1743,7 +1660,7 @@
\unexpanded\def\math_display_align_hack % I don't like the global, maybe we should push and pop
{\global\let\math_display_align_hack_indeed\math_display_align_hack_remove_skip
- \math_openup\displayopenupvalue % was \math_openup\jot
+ \openup\displayopenupvalue % was \openup\jot
\everycr{\noalign{\math_display_align_hack_indeed}}}
\def\math_display_align_hack_remove_skip
@@ -1806,20 +1723,3 @@
\def\mathhorizontalcode#1#2{\ctxcommand{horizontalcode(\number#1,\number#2)}}
\protect \endinput
-
-% % not used (yet)
-%
-% \newtoks \everystartimath
-% \newtoks \everystopimath
-%
-% \unexpanded\def\startimath{\Ustartmath\the\everystartimath}
-% \unexpanded\def\stopimath {\the\everystopimath\Ustopmath}
-%
-% \unexpanded\def\m%
-% {\relax
-% \ifmmode\expandafter\math_m_stay\else\expandafter\math_m_math\fi}
-%
-% \unexpanded\def\math_m_math#1%
-% {\startimath#1\stopimath}
-%
-% \let\math_m_stay\firstofoneargument
diff --git a/tex/context/base/math-map.lua b/tex/context/base/math-map.lua
index 8d301ac33..a0d7457d1 100644
--- a/tex/context/base/math-map.lua
+++ b/tex/context/base/math-map.lua
@@ -21,8 +21,6 @@ if not modules then modules = { } end modules ['math-map'] = {
-- todo: alphabets namespace
-- maybe: script/scriptscript dynamic,
--- superscripped primes get unscripted !
-
-- to be looked into once the fonts are ready (will become font
-- goodie):
--
@@ -38,15 +36,11 @@ local merged = table.merged
local extract = bit32.extract
local allocate = utilities.storage.allocate
-
+local texattribute = tex.attribute
local otffeatures = fonts.constructors.newfeatures("otf")
local registerotffeature = otffeatures.register
-
local setmetatableindex = table.setmetatableindex
-local texgetattribute = tex.getattribute
-local texsetattribute = tex.setattribute
-
local trace_greek = false trackers.register("math.greek", function(v) trace_greek = v end)
local report_remapping = logs.reporter("mathematics","remapping")
@@ -60,30 +54,30 @@ local mathematics = mathematics
-- it otherwise.
mathematics.gaps = {
- [0x1D455] = 0x0210E, -- ℎ h
- [0x1D49D] = 0x0212C, -- ℬ script B
- [0x1D4A0] = 0x02130, -- ℰ script E
- [0x1D4A1] = 0x02131, -- ℱ script F
- [0x1D4A3] = 0x0210B, -- ℋ script H
- [0x1D4A4] = 0x02110, -- ℐ script I
- [0x1D4A7] = 0x02112, -- ℒ script L
- [0x1D4A8] = 0x02133, -- ℳ script M
- [0x1D4AD] = 0x0211B, -- ℛ script R
- [0x1D4BA] = 0x0212F, -- ℯ script e
- [0x1D4BC] = 0x0210A, -- ℊ script g
- [0x1D4C4] = 0x02134, -- ℴ script o
- [0x1D506] = 0x0212D, -- ℭ fraktur C
- [0x1D50B] = 0x0210C, -- ℌ fraktur H
- [0x1D50C] = 0x02111, -- ℑ fraktur I
- [0x1D515] = 0x0211C, -- ℜ fraktur R
- [0x1D51D] = 0x02128, -- ℨ fraktur Z
- [0x1D53A] = 0x02102, -- ℂ bb C
- [0x1D53F] = 0x0210D, -- ℍ bb H
- [0x1D545] = 0x02115, -- ℕ bb N
- [0x1D547] = 0x02119, -- ℙ bb P
- [0x1D548] = 0x0211A, -- ℚ bb Q
- [0x1D549] = 0x0211D, -- ℝ bb R
- [0x1D551] = 0x02124, -- ℤ bb Z
+ [0x1D455] = 0x0210E, -- H
+ [0x1D49D] = 0x0212C, -- script B
+ [0x1D4A0] = 0x02130, -- script E
+ [0x1D4A1] = 0x02131, -- script F
+ [0x1D4A3] = 0x0210B, -- script H
+ [0x1D4A4] = 0x02110, -- script I
+ [0x1D4A7] = 0x02112, -- script L
+ [0x1D4A8] = 0x02133, -- script M
+ [0x1D4AD] = 0x0211B, -- script R
+ [0x1D4BA] = 0x0212F, -- script e
+ [0x1D4BC] = 0x0210A, -- script g
+ [0x1D4C4] = 0x02134, -- script o
+ [0x1D506] = 0x0212D, -- fraktur C
+ [0x1D50B] = 0x0210C, -- fraktur H
+ [0x1D50C] = 0x02111, -- fraktur I
+ [0x1D515] = 0x0211C, -- fraktur R
+ [0x1D51D] = 0x02128, -- fraktur Z
+ [0x1D53A] = 0x02102, -- bb C
+ [0x1D53F] = 0x0210D, -- bb H
+ [0x1D545] = 0x02115, -- bb N
+ [0x1D547] = 0x02119, -- bb P
+ [0x1D548] = 0x0211A, -- bb Q
+ [0x1D549] = 0x0211D, -- bb R
+ [0x1D551] = 0x02124, -- bb Z
}
local function fillinmathgaps(tfmdata,key,value)
@@ -138,7 +132,6 @@ local regular_tf = {
},
symbols = {
[0x2202]=0x2202, [0x2207]=0x2207,
- [0x0027]=0x2032, -- prime
},
}
@@ -171,7 +164,6 @@ local regular_it = {
},
symbols = {
[0x2202]=0x1D715, [0x2207]=0x1D6FB,
- [0x0027]=0x2032, -- prime
},
}
@@ -197,7 +189,6 @@ local regular_bf= {
},
symbols = {
[0x2202]=0x1D6DB, [0x2207]=0x1D6C1,
- [0x0027]=0x2032, -- prime
},
}
@@ -223,7 +214,6 @@ local regular_bi = {
},
symbols = {
[0x2202]=0x1D74F, [0x2207]=0x1D735,
- [0x0027]=0x2032, -- prime
},
}
@@ -274,7 +264,6 @@ local sansserif_bf = {
},
symbols = {
[0x2202]=0x1D789, [0x2207]=0x1D76F,
- [0x0027]=0x2032, -- prime
},
}
@@ -300,7 +289,6 @@ local sansserif_bi = {
},
symbols = {
[0x2202]=0x1D7C3, [0x2207]=0x1D7A9,
- [0x0027]=0x2032, -- prime
},
}
@@ -345,8 +333,7 @@ local blackboard_tf = {
[0x0393]=0x0213E, [0x03A0]=0x0213F,
},
symbols = { -- sum
- [0x2211]=0x02140,
- [0x0027]=0x2032, -- prime
+ [0x2211]=0x02140,
},
}
@@ -537,7 +524,7 @@ function mathematics.getboth(alphabet,style)
end
function mathematics.getstyle(style)
- local r = mathremap[texgetattribute(mathalphabet)]
+ local r = mathremap[texattribute[mathalphabet]]
local alphabet = r and r.alphabet or "regular"
local data = alphabets[alphabet][style]
return data and data.attribute
@@ -546,22 +533,22 @@ end
function mathematics.syncboth(alphabet,style)
local data = alphabet and alphabets[alphabet] or regular
data = style and data[style] or data.tf
- texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet])
+ texattribute[mathalphabet] = data and data.attribute or texattribute[mathalphabet]
end
function mathematics.syncstyle(style)
- local r = mathremap[texgetattribute(mathalphabet)]
+ local r = mathremap[texattribute[mathalphabet]]
local alphabet = r and r.alphabet or "regular"
local data = alphabets[alphabet][style]
- texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet])
+ texattribute[mathalphabet] = data and data.attribute or texattribute[mathalphabet]
end
function mathematics.syncname(alphabet)
-- local r = mathremap[mathalphabet]
- local r = mathremap[texgetattribute(mathalphabet)]
+ local r = mathremap[texattribute[mathalphabet]]
local style = r and r.style or "tf"
local data = alphabets[alphabet][style]
- texsetattribute(mathalphabet,data and data.attribute or texattribute[mathalphabet])
+ texattribute[mathalphabet] = data and data.attribute or texattribute[mathalphabet]
end
local islcgreek = regular_tf.lcgreek
diff --git a/tex/context/base/math-noa.lua b/tex/context/base/math-noa.lua
index f3987c12f..b309ba077 100644
--- a/tex/context/base/math-noa.lua
+++ b/tex/context/base/math-noa.lua
@@ -20,7 +20,6 @@ if not modules then modules = { } end modules ['math-noa'] = {
local utfchar, utfbyte = utf.char, utf.byte
local formatters = string.formatters
-local div = math.div
local fonts, nodes, node, mathematics = fonts, nodes, node, mathematics
@@ -60,10 +59,10 @@ local insert_node_after = node.insert_after
local insert_node_before = node.insert_before
local free_node = node.free
local new_node = node.new -- todo: pool: math_noad math_sub
-local copy_node = node.copy
local new_kern = nodes.pool.kern
local new_rule = nodes.pool.rule
+local concat_nodes = nodes.concat
local topoints = number.points
@@ -76,8 +75,7 @@ local fontemwidths = fonthashes.emwidths
local fontexheights = fonthashes.exheights
local variables = interfaces.variables
-local texsetattribute = tex.setattribute
-local texgetattribute = tex.getattribute
+local texattribute = tex.attribute
local unsetvalue = attributes.unsetvalue
local chardata = characters.data
@@ -120,11 +118,9 @@ local hlist_code = nodecodes.hlist
local glyph_code = nodecodes.glyph
local left_fence_code = 1
-local right_fence_code = 3
local function process(start,what,n,parent)
if n then n = n + 1 else n = 0 end
- local prev = nil
while start do
local id = start.id
if trace_processing then
@@ -152,10 +148,6 @@ local function process(start,what,n,parent)
elseif id == math_char or id == math_textchar or id == math_delim then
break
elseif id == math_noad then
-if prev then
- -- we have no proper prev in math nodes yet
- start.prev = prev
-end
local noad = start.nucleus if noad then process(noad,what,n,start) end -- list
noad = start.sup if noad then process(noad,what,n,start) end -- list
noad = start.sub if noad then process(noad,what,n,start) end -- list
@@ -191,7 +183,6 @@ end
else
-- glue, penalty, etc
end
-prev = start
start = start.next
end
end
@@ -242,39 +233,27 @@ families[math_char] = function(pointer)
local char = pointer.char
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
- pointer.fam = newa
- elseif not fontcharacters[font_of_family(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
- pointer.fam = newa - 3
- end
- else
+ if bold then
pointer[a_exportstatus] = char
pointer.char = 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
- pointer.fam = newa
- end
- else
- local char = pointer.char
- if not fontcharacters[font_of_family(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])
+ 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
- pointer.fam = a
end
+ pointer.fam = newa
+ else
+ if trace_families then
+ local char = pointer.char
+ report_families("family of %C becomes %s with remap %s",char,a,familymap[a])
+ end
+ pointer.fam = a
end
+ else
+ -- pointer.fam = 0
end
end
end
@@ -288,20 +267,8 @@ families[math_delim] = function(pointer)
-- no bold delimiters in unicode
a = a - 3
end
- local char = pointer.small_char
- local okay = fontcharacters[font_of_family(a)][char]
- if okay then
- pointer.small_fam = a
- elseif a > 2 then
- pointer.small_fam = a - 3
- end
- local char = pointer.large_char
- local okay = fontcharacters[font_of_family(a)][char]
- if okay then
- pointer.large_fam = a
- elseif a > 2 then
- pointer.large_fam = a - 3
- end
+ pointer.small_fam = a
+ pointer.large_fam = a
else
pointer.small_fam = 0
pointer.large_fam = 0
@@ -475,20 +442,16 @@ local mathsize = attributes.private("mathsize")
local resize = { } processors.resize = resize
resize[math_fence] = function(pointer)
- local subtype = pointer.subtype
- if subtype == left_fence_code or subtype == right_fence_code then
+ if pointer.subtype == left_fence_code then
local a = pointer[mathsize]
if a and a > 0 then
- local method, size = div(a,100), a % 100
pointer[mathsize] = 0
- local delimiter = pointer.delim
- local chr = delimiter.small_char
- if chr > 0 then
- local fam = delimiter.small_fam
- local id = font_of_family(fam)
- if id > 0 then
- delimiter.small_char = mathematics.big(fontdata[id],chr,size,method)
- end
+ local d = pointer.delim
+ local df = d.small_fam
+ local id = font_of_family(df)
+ if id > 0 then
+ local ch = d.small_char
+ d.small_char = mathematics.big(fontdata[id],ch,a)
end
end
end
@@ -499,35 +462,147 @@ function handlers.resize(head,style,penalties)
return true
end
+-- respacing
+
+-- local mathpunctuation = attributes.private("mathpunctuation")
+--
+-- local respace = { } processors.respace = respace
+
+-- only [nd,ll,ul][po][nd,ll,ul]
+
+-- respace[math_char] = function(pointer,what,n,parent) -- not math_noad .. math_char ... and then parent
+-- pointer = parent
+-- if pointer and pointer.subtype == noad_ord then
+-- local a = pointer[mathpunctuation]
+-- if a and a > 0 then
+-- pointer[mathpunctuation] = 0
+-- local current_nucleus = pointer.nucleus
+-- if current_nucleus.id == math_char then
+-- local current_char = current_nucleus.char
+-- local fc = chardata[current_char]
+-- fc = fc and fc.category
+-- if fc == "nd" or fc == "ll" or fc == "lu" then
+-- local next_noad = pointer.next
+-- if next_noad and next_noad.id == math_noad and next_noad.subtype == noad_punct then
+-- local next_nucleus = next_noad.nucleus
+-- if next_nucleus.id == math_char then
+-- local next_char = next_nucleus.char
+-- local nc = chardata[next_char]
+-- nc = nc and nc.category
+-- if nc == "po" then
+-- local last_noad = next_noad.next
+-- if last_noad and last_noad.id == math_noad and last_noad.subtype == noad_ord then
+-- local last_nucleus = last_noad.nucleus
+-- if last_nucleus.id == math_char then
+-- local last_char = last_nucleus.char
+-- local lc = chardata[last_char]
+-- lc = lc and lc.category
+-- if lc == "nd" or lc == "ll" or lc == "lu" then
+-- local ord = new_node(math_noad) -- todo: pool
+-- ord.subtype, ord.nucleus, ord.sub, ord.sup, ord.attr = noad_ord, next_noad.nucleus, next_noad.sub, next_noad.sup, next_noad.attr
+-- -- next_noad.nucleus, next_noad.sub, next_noad.sup, next_noad.attr = nil, nil, nil, nil
+-- next_noad.nucleus, next_noad.sub, next_noad.sup = nil, nil, nil -- else crash with attributes ref count
+-- --~ next_noad.attr = nil
+-- ord.next = last_noad
+-- pointer.next = ord
+-- free_node(next_noad)
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+
+-- local comma = 0x002C
+-- local period = 0x002E
+--
+-- respace[math_char] = function(pointer,what,n,parent)
+-- pointer = parent
+-- if pointer and pointer.subtype == noad_punct then
+-- local current_nucleus = pointer.nucleus
+-- if current_nucleus.id == math_char then
+-- local current_nucleus = pointer.nucleus
+-- if current_nucleus.id == math_char then
+-- local current_char = current_nucleus.char
+-- local a = pointer[mathpunctuation]
+-- if not a or a == 0 then
+-- if current_char == comma then
+-- -- default tex: 2,5 or 2, 5 --> 2, 5
+-- elseif current_char == period then
+-- -- default tex: 2.5 or 2. 5 --> 2.5
+-- pointer.subtype = noad_ord
+-- end
+-- elseif a == 1 then
+-- local next_noad = pointer.next
+-- if next_noad and next_noad.id == math_noad then
+-- local next_nucleus = next_noad.nucleus
+-- if next_nucleus.id == math_char and next_nucleus.char == 0 then
+-- nodes.remove(pointer,next_noad,true)
+-- end
+-- if current_char == comma then
+-- -- default tex: 2,5 or 2, 5 --> 2, 5
+-- elseif current_char == period then
+-- -- default tex: 2.5 or 2. 5 --> 2.5
+-- pointer.subtype = noad_ord
+-- end
+-- end
+-- elseif a == 2 then
+-- if current_char == comma or current_char == period then
+-- local next_noad = pointer.next
+-- if next_noad and next_noad.id == math_noad then
+-- local next_nucleus = next_noad.nucleus
+-- if next_nucleus.id == math_char and next_nucleus.char == 0 then
+-- if current_char == comma then
+-- -- adaptive: 2, 5 --> 2, 5
+-- elseif current_char == period then
+-- -- adaptive: 2. 5 --> 2. 5
+-- end
+-- nodes.remove(pointer,next_noad,true)
+-- else
+-- if current_char == comma then
+-- -- adaptive: 2,5 --> 2,5
+-- pointer.subtype = noad_ord
+-- elseif current_char == period then
+-- -- adaptive: 2.5 --> 2.5
+-- pointer.subtype = noad_ord
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+-- end
+--
+-- function handlers.respace(head,style,penalties)
+-- processnoads(head,respace,"respace")
+-- return true
+-- end
+
+-- The following code is dedicated to Luigi Scarso who pointed me
+-- to the fact that \not= is not producing valid pdf-a code.
+-- The code does not solve this for virtual characters but it does
+-- a decent job on collapsing so that fonts that have the right
+-- glyph will have a decent unicode point. In the meantime this code
+-- has been moved elsewhere.
local collapse = { } processors.collapse = collapse
local mathpairs = characters.mathpairs
-mathpairs[0x2032] = { [0x2032] = 0x2033, [0x2033] = 0x2034, [0x2034] = 0x2057 } -- (prime,prime) (prime,doubleprime) (prime,tripleprime)
-mathpairs[0x2033] = { [0x2032] = 0x2034, [0x2033] = 0x2057 } -- (doubleprime,prime) (doubleprime,doubleprime)
-mathpairs[0x2034] = { [0x2032] = 0x2057 } -- (tripleprime,prime)
-
-mathpairs[0x2035] = { [0x2035] = 0x2036, [0x2036] = 0x2037 } -- (reversedprime,reversedprime) (reversedprime,doublereversedprime)
-mathpairs[0x2036] = { [0x2035] = 0x2037 } -- (doublereversedprime,reversedprime)
+mathpairs[0x2032] = { [0x2032] = 0x2033, [0x2033] = 0x2034 } -- (prime,prime) (prime,doubleprime)
+mathpairs[0x2033] = { [0x2032] = 0x2034 } -- (doubleprime,prime)
mathpairs[0x222B] = { [0x222B] = 0x222C, [0x222C] = 0x222D }
mathpairs[0x222C] = { [0x222B] = 0x222D }
-mathpairs[0x007C] = { [0x007C] = 0x2016, [0x2016] = 0x2980 } -- bar+bar=double bar+double=triple
-mathpairs[0x2016] = { [0x007C] = 0x2980 } -- double+bar=triple
-
-local movesub = {
- -- primes
- [0x2032] = 0xFE932,
- [0x2033] = 0xFE933,
- [0x2034] = 0xFE934,
- [0x2057] = 0xFE957,
- -- reverse primes
- [0x2035] = 0xFE935,
- [0x2036] = 0xFE936,
- [0x2037] = 0xFE937,
-}
+mathpairs[0x007C] = { [0x007C] = 0x2016 } -- double bars
local validpair = {
[noad_rel] = true,
@@ -537,79 +612,48 @@ local validpair = {
[noad_opnolimits] = true,
}
-local function movesubscript(parent,current_nucleus,current_char)
- local prev = parent.prev
- if prev and prev.id == math_noad then
- if not prev.sup and not prev.sub then
- current_nucleus.char = movesub[current_char or current_nucleus.char]
- -- {f} {'}_n => f_n^'
- local nucleus = parent.nucleus
- local sub = parent.sub
- local sup = parent.sup
- prev.sup = nucleus
- prev.sub = sub
- local dummy = copy_node(nucleus)
- dummy.char = 0
- parent.nucleus = dummy
- parent.sub = nil
- if trace_collapsing then
- report_collapsing("fixing subscript")
- end
- end
- end
-end
-
-local function collapsepair(pointer,what,n,parent,nested) -- todo: switch to turn in on and off
+local function collapsepair(pointer,what,n,parent) -- todo: switch to turn in on and off
if parent then
if validpair[parent.subtype] then
local current_nucleus = parent.nucleus
- if current_nucleus.id == math_char then
+ if not parent.sub and not parent.sup and current_nucleus.id == math_char then
local current_char = current_nucleus.char
- if not parent.sub and not parent.sup then
- local mathpair = mathpairs[current_char]
- if mathpair then
- local next_noad = parent.next
- if next_noad and next_noad.id == math_noad then
- if validpair[next_noad.subtype] then
- local next_nucleus = next_noad.nucleus
- if next_nucleus.id == math_char then
- local next_char = next_nucleus.char
- local newchar = mathpair[next_char]
- if newchar then
- local fam = current_nucleus.fam
- local id = font_of_family(fam)
- local characters = fontcharacters[id]
- if characters and characters[newchar] then
- if trace_collapsing then
- report_collapsing("%U + %U => %U",current_char,next_char,newchar)
- end
- current_nucleus.char = newchar
- local next_next_noad = next_noad.next
- if next_next_noad then
- parent.next = next_next_noad
- next_next_noad.prev = parent
- else
- parent.next = nil
- end
- parent.sup = next_noad.sup
- parent.sub = next_noad.sub
- next_noad.sup = nil
- next_noad.sub = nil
- free_node(next_noad)
- collapsepair(pointer,what,n,parent,true)
- if not nested and movesub[current_char] then
- movesubscript(parent,current_nucleus)
- end
+ local mathpair = mathpairs[current_char]
+ if mathpair then
+ local next_noad = parent.next
+ if next_noad and next_noad.id == math_noad then
+ if validpair[next_noad.subtype] then
+ local next_nucleus = next_noad.nucleus
+ if next_nucleus.id == math_char then
+ local next_char = next_nucleus.char
+ local newchar = mathpair[next_char]
+ if newchar then
+ local fam = current_nucleus.fam
+ local id = font_of_family(fam)
+ local characters = fontcharacters[id]
+ if characters and characters[newchar] then
+ if trace_collapsing then
+ report_collapsing("%U + %U => %U",current_char,next_char,newchar)
+ end
+ current_nucleus.char = newchar
+ local next_next_noad = next_noad.next
+ if next_next_noad then
+ parent.next = next_next_noad
+ next_next_noad.prev = parent
+ else
+ parent.next = nil
end
+ parent.sup = next_noad.sup
+ parent.sub = next_noad.sub
+ next_noad.sup = nil
+ next_noad.sub = nil
+ free_node(next_noad)
+ collapsepair(pointer,what,n,parent)
end
end
end
end
- elseif not nested and movesub[current_char] then
- movesubscript(parent,current_nucleus,current_char)
end
- elseif not nested and movesub[current_char] then
- movesubscript(parent,current_nucleus,current_char)
end
end
end
@@ -780,7 +824,7 @@ function mathematics.setalternate(fam,tag)
local mathalternates = tfmdata.shared and tfmdata.shared.mathalternates
if mathalternates then
local m = mathalternates[tag]
- texsetattribute(a_mathalternate,m and m.attribute or unsetvalue)
+ tex.attribute[a_mathalternate] = m and m.attribute or unsetvalue
end
end
@@ -903,8 +947,11 @@ trackers.register("math.italics", function(v)
if k > 0 then
return setcolor(new_rule(k,ex,ex),c_positive_d)
else
- -- influences un*
- return old_kern(k) .. setcolor(new_rule(-k,ex,ex),c_negative_d) .. old_kern(k)
+ return concat_nodes {
+ old_kern(k),
+ setcolor(new_rule(-k,ex,ex),c_negative_d),
+ old_kern(k),
+ }
end
end
else
@@ -1016,14 +1063,14 @@ function mathematics.setitalics(n)
enable()
end
if n == variables.reset then
- texsetattribute(a_mathitalics,unsetvalue)
+ texattribute[a_mathitalics] = unsetvalue
else
- texsetattribute(a_mathitalics,tonumber(n) or unsetvalue)
+ texattribute[a_mathitalics] = tonumber(n) or unsetvalue
end
end
function mathematics.resetitalics()
- texsetattribute(a_mathitalics,unsetvalue)
+ texattribute[a_mathitalics] = unsetvalue
end
-- variants
@@ -1087,50 +1134,6 @@ function handlers.variants(head,style,penalties)
return true
end
--- for manuals
-
-local classes = { }
-
-local colors = {
- [noadcodes.rel] = "trace:dr",
- [noadcodes.ord] = "trace:db",
- [noadcodes.bin] = "trace:dg",
- [noadcodes.open] = "trace:dm",
- [noadcodes.close] = "trace:dm",
- [noadcodes.punct] = "trace:dc",
- -- [noadcodes.opdisplaylimits] = "",
- -- [noadcodes.oplimits] = "",
- -- [noadcodes.opnolimits] = "",
- -- [noadcodes.inner = "",
- -- [noadcodes.under = "",
- -- [noadcodes.over = "",
- -- [noadcodes.vcenter = "",
-}
-
-classes[math_char] = function(pointer,what,n,parent)
- local color = colors[parent.subtype]
- if color then
- setcolor(pointer,color)
- else
- resetcolor(pointer)
- end
-end
-
-function handlers.classes(head,style,penalties)
- processnoads(head,classes,"classes")
- return true
-end
-
-trackers.register("math.classes",function(v) tasks.setaction("math","noads.handlers.classes",v) end)
-
--- just for me
-
-function handlers.showtree(head,style,penalties)
- inspect(nodes.totree(head))
-end
-
-trackers.register("math.showtree",function(v) tasks.setaction("math","noads.handlers.showtree",v) end)
-
-- the normal builder
function builders.kernel.mlist_to_hlist(head,style,penalties)
diff --git a/tex/context/base/math-pln.mkiv b/tex/context/base/math-pln.mkiv
index 5e4c43c81..b862bb4cb 100644
--- a/tex/context/base/math-pln.mkiv
+++ b/tex/context/base/math-pln.mkiv
@@ -87,31 +87,13 @@
\unexpanded\def\pmatrix#1%
{\left(\matrix{#1}\right)}
-% \unexpanded\def\openup
-% {\afterassignment\math_openup\scratchdimen=}
-%
-% \def\math_openup
-% {\advance\lineskip \scratchdimen
-% \advance\baselineskip \scratchdimen
-% \advance\lineskiplimit\scratchdimen}
-
-\let\math_closeup\relax
-
-\unexpanded\def\math_openup
- {\afterassignment\math_openup_indeed\scratchdimen}
-
-\def\math_openup_indeed
- {\unexpanded\edef\math_closeup
- {\lineskip \the\lineskip
- \baselineskip \the\baselineskip
- \lineskiplimit\the\lineskiplimit
- \relax}%
- \advance \lineskip \scratchdimen
- \advance \baselineskip \scratchdimen
- \advance \lineskiplimit \scratchdimen}
-
-\let\openup \math_openup
-\def\closeup{\math_closeup} % dynamic
+\unexpanded\def\openup
+ {\afterassignment\math_openup\scratchdimen=}
+
+\def\math_openup
+ {\advance\lineskip \scratchdimen
+ \advance\baselineskip \scratchdimen
+ \advance\lineskiplimit\scratchdimen}
\unexpanded\def\displaylines#1%
{\the\mathdisplayaligntweaks
diff --git a/tex/context/base/math-rad.mkvi b/tex/context/base/math-rad.mkvi
deleted file mode 100644
index 541a7038e..000000000
--- a/tex/context/base/math-rad.mkvi
+++ /dev/null
@@ -1,287 +0,0 @@
-%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
-
-\def\root#1\of{\rootradical{#1}} % #2
-
-\unexpanded\def\sqrt{\doifnextoptionalelse\rootwithdegree\rootwithoutdegree}
-
-\def\rootwithdegree[#1]{\rootradical{#1}}
-\def\rootwithoutdegree {\rootradical {}}
-
-%D Even older stuff:
-
-% % is now a ordinary character
-%
-% \let\normalsurd\surd % \Uradical "0 "221A
-% \unexpanded\def\surd{\normalsurd{}}
-
-
-%D The real thing:
-
-\installcorenamespace{mathradical}
-\installcorenamespace{mathradicalalternative}
-
-\installcommandhandler \??mathradical {mathradical} \??mathradical
-
-\setupmathradical
- [\c!alternative=\v!normal,
- \c!mpoffset=.25\exheight]
-
-\appendtoks
- \setuevalue{\currentmathradical}{\math_radical_handle{\currentmathradical}}
-\to \everydefinemathradical
-
-\unexpanded\def\math_radical_handle#tag%
- {\begingroup
- \edef\currentmathradical{#tag}%
- \doifnextoptionalelse\math_radical_degree_yes\math_radical_degree_nop}
-
-\def\math_radical_alternative{\csname\??mathradicalalternative\mathradicalparameter\c!alternative\endcsname}
-
-\def\m_math_no_degree{{}}
-
-\def\math_radical_degree_yes[#degree]{\edef\currentmathradicaldegree{#degree}\math_radical_indeed}
-\def\math_radical_degree_nop {\let\currentmathradicaldegree\m_math_no_degree\math_radical_indeed}
-
-\def\math_radical_indeed#body%
- {\math_radical_alternative{#body}\endgroup}
-
-\setvalue{\??mathradicalalternative\v!default}% #1%
- {\rootradical{\currentmathradicaldegree}}
-
-\setvalue{\??mathradicalalternative\v!normal}#body%
- {\edef\p_color{\mathradicalparameter\c!color}%
- \ifx\p_color\empty
- \rootradical{\currentmathradicaldegree}{#body}% {} really needed as \rootradical expands first
- \else\ifx\currentmathradicaldegree\empty
- \pushcolor[\p_color]%
- \rootradical{\currentmathradicaldegree}%
- {\popcolor#body}%
- \else
- \pushcolor[\p_color]%
- \rootradical{\popcolor\currentmathradicaldegree\pushcolor[\p_color]}%
- {\popcolor#body}%
- \fi\fi}
-
-% As I had a long standing whish to see a proper final root element I decided
-% to make one my own.
-%
-% \startMPcode
-% path p ; p := unitsquare xysized(4cm,1cm) ;
-%
-% path q ; q := boundingbox p enlarged (bbheight(p)/10) ;
-% numeric h ; h := bbheight(q) ;
-%
-% draw p ;
-% draw
-% llcorner q shifted (-h/2,h/2) --
-% llcorner q shifted (-h/4,0) --
-% ulcorner q --
-% urcorner q --
-% urcorner q shifted (0,-h/10) ;
-% \stopMPcode
-%
-% \startMPextensions
-% vardef math_root(expr w,h,d,o) =
-% path q ; q := boundingbox unitsquare xysized(w,h) enlarged (o);
-% llcorner q shifted (-h/2,h/2) --
-% llcorner q shifted (-h/4,-d) --
-% ulcorner q --
-% urcorner q --
-% urcorner q shifted (0,-h/10)
-% enddef ;
-% \stopMPextensions
-%
-% \startuniqueMPgraphic{root}{width,height,depth,offset,linewidth}
-% pickup pencircle scaled \MPvar{linewidth} ;
-% draw math_root(\MPvar{width},\MPvar{height},\MPvar{depth},\MPvar{offset}) ;
-% \stopuniqueMPgraphic
-%
-% \unexpanded\def\sqrt#1%
-% {\begingroup
-% \setbox\scratchbox\mathstylehbox{#1}%
-% \scratchoffset\MPrawvar{root}{offset}%.25\exheight
-% \scratchwidth \wd\scratchbox
-% \scratchheight\ht\scratchbox
-% \scratchdepth \dp\scratchbox
-% \setbox2=\hbox\bgroup % todo: tag this box as sqrt
-% \uniqueMPgraphic
-% {root}%
-% {width=\the\scratchwidth,%
-% depth=\the\scratchdepth,%
-% height=\the\scratchheight,%
-% offset=\the\scratchoffset,
-% linewidth=\the\linewidth}%
-% \egroup
-% \scratchdimen\wd2
-% \lower\dimexpr\scratchoffset+\scratchdepth\relax\box2
-% \hskip-\scratchdimen
-% \hbox to \scratchdimen{\hss\box\scratchbox\hskip\scratchoffset}%
-% \endgroup}
-
-\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{math:radical:default}%{...}
- draw
- math_radical_simple(OverlayWidth,OverlayHeight,OverlayDepth,OverlayOffset)
- withpen pencircle xscaled (2OverlayLineWidth) yscaled (3OverlayLineWidth/4) rotated 30
- % 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
- \edef\overlaywidth {\the\wd\nextbox}%
- \edef\overlayheight {\the\ht\nextbox}%
- \edef\overlaydepth {\the\dp\nextbox}%
- \edef\overlayoffset {\the\scratchoffset}%
- \edef\overlaylinewidth{\the\linewidth}%
- \edef\overlaylinecolor{\mathradicalparameter\c!color}%
- %
- \edef\p_mp{\mathradicalparameter\c!mp}%
- %
- \setbox\scratchbox\hbox\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
- \hbox 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=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 juglers 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
- \setuevalue{\currentmathornament}{\math_ornament_handle{\currentmathornament}}
-\to \everydefinemathornament
-
-\unexpanded\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}%
- \edef\overlaywidth {\the\wd\nextbox}%
- \edef\overlayheight {\the\ht\nextbox}%
- \edef\overlaydepth {\the\dp\nextbox}%
- \edef\overlayoffset {\the\scratchoffset}%
- \edef\overlaylinewidth{\the\linewidth}%
- \edef\overlaylinecolor{\mathornamentparameter\c!color}%
- \edef\p_mp{\mathornamentparameter\c!mp}%
- % thw width of the graphic determines the width of the final result
- \setbox\scratchbox\hbox{\uniqueMPgraphic{\p_mp}}% todo: add code key + tag
- \scratchdimen \wd\scratchbox
- % \scratchtopoffset \dimexpr\scratchoffset+\dp\nextbox\relax
- % \scratchbottomoffset\dimexpr\scratchoffset+\ht\nextbox/2\relax
- \hbox to \scratchdimen{\hss\box\nextbox\hss}%
- \hskip-\scratchdimen
- \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/tex/context/base/math-ren.lua b/tex/context/base/math-ren.lua
index 5c4c13369..2e7dba13d 100644
--- a/tex/context/base/math-ren.lua
+++ b/tex/context/base/math-ren.lua
@@ -63,3 +63,7 @@ mathematics.renderset = renderset
function commands.mathrenderset(list)
context(renderset(list))
end
+
+-- function commands.setmatrendering(list)
+-- tex.setattribute(renderset(list))
+-- end
diff --git a/tex/context/base/math-stc.mkvi b/tex/context/base/math-stc.mkvi
index 76a07db5c..2dc2b2c22 100644
--- a/tex/context/base/math-stc.mkvi
+++ b/tex/context/base/math-stc.mkvi
@@ -48,10 +48,6 @@
%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.
-
% possible improvements:
%
% - we could skip the left/right offsets when offset=normal, this saves some access time
@@ -60,40 +56,27 @@
\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_regular
-% {\mathstylehbox{\Umathaccent\fam\zerocount\scratchunicode{\hskip\scratchwidth}}}
-
\def\math_stackers_regular
- {\mathstylehbox{\usemathstackerscolorparameter\c!color
- \Umathaccent\fam\zerocount\scratchunicode{\hskip\scratchwidth}}}
+ {\mathstylehbox{\Umathaccent\fam\zerocount\scratchunicode{\hskip\scratchwidth}}}
\def\math_stackers_stretch % we don't have that one yet
- {\mathstylehbox{\usemathstackerscolorparameter\c!color
- \Umathaccent\fam\zerocount\scratchunicode{\hskip\hsize}}}
-
-% these delimiters are a unuseable as theu 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
+ {\mathstylehbox{\Umathaccent\fam\zerocount\scratchunicode{\hskip\hsize}}}
\setvalue{\??mathextensiblefallbacks}{\hbox{\vrule\!!width\scratchwidth\!!height.1\exheight\!!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}
+\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\
@@ -131,12 +114,6 @@
[%c!alternative=\v!text, % text | mathematics
\c!left=,
\c!right=,
- \c!mathclass=\s!rel,
- \c!alternative=\v!normal,
- \c!mp=math:stacker:\number\scratchunicode,
- \c!mpheight=\exheight,
- \c!mpdepth=\exheight,
- \c!mpoffset=.25\exheight,
\c!voffset=.25\exheight,
\c!hoffset=.5\emwidth,
\c!minheight=\exheight,
@@ -144,7 +121,7 @@
\c!minwidth=\emwidth,
\c!order=\v!normal,
\c!strut=,
- \c!color=, % todo: when I need it
+ %\c!color=, % todo: when I need it
\c!topcommand=,
\c!middlecommand=,
\c!bottomcommand=,
@@ -155,7 +132,6 @@
%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
@@ -196,23 +172,6 @@
\math_stackers_fallback
\fi}
-% no checking, we assume sane use
-
-\letvalue{\??mathstackersalternative\v!normal }\math_stackers_content
-\letvalue{\??mathstackersalternative\v!default}\math_stackers_content
-
-\setvalue{\??mathstackersalternative\v!mp}%
- {\hbox\bgroup % todo: add code key + tag
- \edef\overlaywidth {\the\scratchwidth}%
- \edef\overlayheight {\the\dimexpr\mathstackersparameter\c!mpheight}%
- \edef\overlaydepth {\the\dimexpr\mathstackersparameter\c!mpdepth}%
- \edef\overlayoffset {\the\dimexpr\mathstackersparameter\c!mpoffset}%
- \edef\overlaylinewidth{\the\linewidth}%
- \edef\overlaylinecolor{\mathstackersparameter\c!color}%
- \edef\p_mp{\mathstackersparameter\c!mp}%
- \uniqueMPgraphic{\p_mp}%
- \egroup}
-
\def\math_stackers_check_unicode#codepoint%
{\scratchunicode#codepoint\relax
\scratchhoffset\mathstackersparameter\c!hoffset\relax
@@ -264,12 +223,11 @@
{\begingroup
\edef\currentmathstackers{#category}%
\mathstackersparameter\c!left\relax
- \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
- {\edef\p_offset {\mathstackersparameter\c!offset}%
- \edef\p_location {\mathstackersparameter\c!location}%
- \edef\p_order {\mathstackersparameter\c!order}%
- \edef\p_strut {\mathstackersparameter\c!strut}%
- \edef\p_alternative{\mathstackersparameter\c!alternative}%
+ \ifmmode\mathrel\else\dontleavehmode\fi
+ {\edef\p_offset {\mathstackersparameter\c!offset}%
+ \edef\p_location{\mathstackersparameter\c!location}%
+ \edef\p_order {\mathstackersparameter\c!order}%
+ \edef\p_strut {\mathstackersparameter\c!strut}%
\ifx\p_order\v!reverse
\edef\m_math_stackers_text_top {#bottomtext}%
\edef\m_math_stackers_text_bottom{#toptext}%
@@ -327,17 +285,17 @@
\advance\scratchwidth2\scratchhoffset
%
\ifcase#method\relax
- \setbox\scratchboxthree\csname\??mathstackersalternative\p_alternative\endcsname
+ \setbox\scratchboxthree\math_stackers_content
\fi
%
\ifdim\wd\scratchboxone<\scratchwidth
- \setbox\scratchboxone\hbox to \scratchwidth{\hss\unhbox\scratchboxone\hss}% unhboxing makes leaders work
+ \setbox\scratchboxone\hbox to \scratchwidth{\hss\box\scratchboxone\hss}%
\fi
\ifdim\wd\scratchboxtwo<\scratchwidth
- \setbox\scratchboxtwo\hbox to \scratchwidth{\hss\unhbox\scratchboxtwo\hss}%
+ \setbox\scratchboxtwo\hbox to \scratchwidth{\hss\box\scratchboxtwo\hss}%
\fi
\ifdim\wd\scratchboxthree<\scratchwidth
- \setbox\scratchboxthree\hbox to \scratchwidth{\hss\unhbox\scratchboxthree\hss}%
+ \setbox\scratchboxthree\hbox to \scratchwidth{\hss\box\scratchboxthree\hss}%
\fi
%
\ifcsname\??mathstackerslocation\p_location\endcsname
@@ -437,30 +395,17 @@
%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}
-
-\unexpanded\def\math_stackers_make_double#top#bottom#category#codepoint#codeextra#text%
+\unexpanded\def\math_stackers_double#where#category#codepoint#text%
{\begingroup
\edef\currentmathstackers{#category}%
\mathstackersparameter\c!left\relax
- \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
+ \ifmmode\mathrel\else\dontleavehmode\fi
{\edef\currentmathstackers{#category}%
\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}%
+ \edef\p_offset {\mathstackersparameter\c!offset}%
+ \edef\p_location{\mathstackersparameter\c!location}%
+ \edef\p_strut {\mathstackersparameter\c!strut}%
%
\scratchleftoffset \zeropoint
\scratchrightoffset\zeropoint
@@ -480,7 +425,7 @@
\fi
\advance\scratchwidth2\scratchhoffset
%
- \setbox\scratchboxtwo \csname\??mathstackersalternative\p_alternative\endcsname
+ \setbox\scratchboxtwo \math_stackers_content
\setbox\scratchboxthree\hbox to \scratchwidth{\hss\box\scratchboxthree\hss}%
%
\math_stackers_normalize_three
@@ -491,74 +436,49 @@
%
\ifdim\htdp\scratchboxtwo>\zeropoint
\kern-\scratchwidth
- \ifcase#top\else
+ \ifcase#where\relax
\math_stackers_top\bgroup
- % \raise\dimexpr\scratchheight+\scratchtopoffset\relax
- \raise\dimexpr\scratchheight+\mathstackersparameter\c!voffset\relax
+ \raise\dimexpr\scratchheight+\scratchtopoffset\relax
\box\scratchboxtwo
\egroup
- \fi
- \scratchunicode#codeextra\relax
- \ifcase\scratchunicode\else
- \kern-\scratchwidth
- \setbox\scratchboxtwo\csname\??mathstackersalternative\p_alternative\endcsname
- \fi
- \ifcase#bottom\else
+ \else
\math_stackers_bottom\bgroup
- % \lower\dimexpr\scratchdepth+\ht\scratchboxtwo+\scratchbottomoffset\relax
- \lower\dimexpr\scratchdepth+\ht\scratchboxtwo+\mathstackersparameter\c!voffset\relax
+ \lower\dimexpr\scratchdepth+\ht\scratchboxtwo+\scratchbottomoffset\relax
\box\scratchboxtwo
\egroup
\fi
\fi}%
\mathstackersparameter\c!right\relax
- \edef\p_limits{\mathstackersparameter\c!mathlimits}%
- \ifx\p_limits\v!yes
- \expandafter\endgroup\expandafter\limits
- \else
- \expandafter\endgroup
- \fi}
-
-\unexpanded\def\definemathoverextensible {\dotripleempty \math_extensibles_define_over }
-\unexpanded\def\definemathunderextensible {\dotripleempty \math_extensibles_define_under}
-\unexpanded\def\definemathdoubleextensible{\doquadrupleempty\math_extensibles_define_double}
-
-\def\math_extensibles_define_over[#1][#2][#3]%
- {\ifthirdargument
- \setuevalue{#2}{\math_stackers_make_double\plusone \zerocount{#1}{\number#3}{0}}%
- \else
- \setuevalue{#1}{\math_stackers_make_double\plusone \zerocount\noexpand\currentmathstackers{\number#2}{0}}%
- \fi}
+ \endgroup}
-\def\math_extensibles_define_under[#1][#2][#3]%
+\unexpanded\def\definemathoverextensible {\dotripleempty\math_extensiblies_define_over }
+\unexpanded\def\definemathunderextensible{\dotripleempty\math_extensiblies_define_under}
+
+\def\math_extensiblies_define_over[#1][#2][#3]%
{\ifthirdargument
- \setuevalue{#2}{\math_stackers_make_double\zerocount\plusone{#1}{\number#3}{0}}%
+ \setuevalue{#2}{\math_stackers_double\zerocount{#1}{\number#3}}%
\else
- \setuevalue{#1}{\math_stackers_make_double\zerocount\plusone\noexpand\currentmathstackers{\number#2}{0}}%
+ \setuevalue{#1}{\math_stackers_double\zerocount\noexpand\currentmathstackers{\number#2}}%
\fi}
-\def\math_extensibles_define_double[#1][#2][#3][#4]%
- {\iffourthargument
- \setuevalue{#2}{\math_stackers_make_double\plusone \plusone{#1}{\number#3}{\number#4}}%
+\def\math_extensiblies_define_under[#1][#2][#3]%
+ {\ifthirdargument
+ \setuevalue{#2}{\math_stackers_double\plusone{#1}{\number#3}}%
\else
- \setuevalue{#1}{\math_stackers_make_double\plusone \plusone\noexpand\currentmathstackers{\number#2}{\number#3}}%
+ \setuevalue{#1}{\math_stackers_double\plusone\noexpand\currentmathstackers{\number#2}}%
\fi}
-\unexpanded\def\mathover {\begingroup\dosingleempty\math_stackers_handle_over }
-\unexpanded\def\mathunder {\begingroup\dosingleempty\math_stackers_handle_under }
-\unexpanded\def\mathdouble{\begingroup\dodoubleempty\math_stackers_handle_double}
+\unexpanded\def\mathover {\begingroup\dosingleempty\math_stackers_handle_over }
+\unexpanded\def\mathunder{\begingroup\dosingleempty\math_stackers_handle_under}
\def\math_stackers_handle_over[#category]%
- {\math_stackers_direct_double\plusone\zerocount{\iffirstargument#category\else\v!top \fi}} % will be defined later on
+ {\math_stackers_handle_double\zerocount{\iffirstargument#category\else\v!top \fi}} % will be defined later on
\def\math_stackers_handle_under[#category]#codepoint#bottomtext%
- {\math_stackers_direct_double\zerocount\plusone{\iffirstargument#category\else\v!bottom\fi}} % will be defined later on
-
-\def\math_stackers_handle_double[#category]#codepoint#bottomtext%
- {\math_stackers_direct_double\plusone\plusone {\iffirstargument#category\else\v!bottom\fi}} % will be defined later on
+ {\math_stackers_handle_double\plusone {\iffirstargument#category\else\v!bottom\fi}} % will be defined later on
-\def\math_stackers_direct_double#top#bottom#category#codepoint#text%
- {\math_stackers_make_double#top#bottom{#category}{#codepoint}{#text}%
+\def\math_stackers_handle_double#location#category#codepoint#text%
+ {\math_stackers_double#location{#category}{#codepoint}{#text}%
\endgroup}
%D Here is a bonus macro that takes three texts. It can be used to get consistent
@@ -638,79 +558,23 @@
[\c!order=\v!reverse]
\definemathstackers
- [\v!both]
+ [\v!top]
[\v!mathematics]
- [\c!location=\v!top, % ?
+ [\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
- [vfenced]
- [\v!both]
- [\c!mathclass=\s!ord,
- \c!mathlimits=\v!yes]
+ [\v!mathematics]
+ [\c!location=\v!top,
+ \c!strut=\v!no,
+ \c!middlecommand=\mathematics,
+ \c!hoffset=\zeropoint]
% 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
-
-\unexpanded\def\normaldoublebrace {\Umathaccents 0 \defaultmathfamily "23DE 0 \defaultmathfamily "23DF }
-\unexpanded\def\normaldoubleparent{\Umathaccents 0 \defaultmathfamily "23DC 0 \defaultmathfamily "23DD }
-
-% let's keep this
-
-\let\normaloverbrace \overbrace
-\let\normalunderbrace \underbrace
-\let\normaloverparent \overparent
-\let\normalunderparent \underparent
-\let\normaloverbracket \overbracket
-\let\normalunderbracket \underbracket
-\let\normalunderleftarrow \underleftarrow
-\let\normaloverleftarrow \overleftarrow
-\let\normalunderrightarrow\underrightarrow
-\let\normaloverrightarrow \overrightarrow
-
-\let\lceil \lceiling
-\let\rceil \rceiling
-
-%D Here come the new ones:
-
\definemathstackers [\v!none] [\v!mathematics] [\c!hoffset=\zeropoint]
\definemathstackers [\v!normal] [\v!mathematics] [\c!hoffset=0.5\emwidth] % the default
\definemathstackers [\v!small] [\v!mathematics] [\c!hoffset=1\emwidth]
@@ -719,12 +583,8 @@
\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] [xleftarrow] ["2190]
+\definemathextensible [\v!reverse] [xrightarrow] ["2192]
\definemathextensible [\v!reverse] [xtwoheadleftarrow] ["219E]
\definemathextensible [\v!reverse] [xtwoheadrightarrow] ["21A0]
\definemathextensible [\v!reverse] [xmapsto] ["21A6]
@@ -738,15 +598,15 @@
\definemathextensible [\v!reverse] [xleftrightharpoons] ["21CB]
\definemathextensible [\v!reverse] [xrightleftharpoons] ["21CC]
\definemathextensible [\v!reverse] [xtriplerel] ["2261]
+\definemathextensible [\v!reverse] [xleftrightarrow] ["27F7]
+\definemathextensible [\v!reverse] [xLeftarrow] ["27F8]
+\definemathextensible [\v!reverse] [xRightarrow] ["27F9]
+\definemathextensible [\v!reverse] [xLeftrightarrow] ["27FA]
\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] [mleftarrow] ["2190]
+\definemathextensible [\v!mathematics] [mrightarrow] ["2192]
\definemathextensible [\v!mathematics] [mtwoheadleftarrow] ["219E]
\definemathextensible [\v!mathematics] [mtwoheadrightarrow] ["21A0]
\definemathextensible [\v!mathematics] [mmapsto] ["21A6]
@@ -760,18 +620,18 @@
\definemathextensible [\v!mathematics] [mleftrightharpoons] ["21CB]
\definemathextensible [\v!mathematics] [mrightleftharpoons] ["21CC]
\definemathextensible [\v!mathematics] [mtriplerel] ["2261]
+\definemathextensible [\v!mathematics] [mleftrightarrow] ["27F7]
+\definemathextensible [\v!mathematics] [mLeftarrow] ["27F8]
+\definemathextensible [\v!mathematics] [mRightarrow] ["27F9]
+\definemathextensible [\v!mathematics] [mLeftrightarrow] ["27FA]
\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] [tleftarrow] ["2190]
+\definemathextensible [\v!text] [trightarrow] ["2192]
\definemathextensible [\v!text] [ttwoheadleftarrow] ["219E]
\definemathextensible [\v!text] [ttwoheadrightarrow] ["21A0]
+\definemathextensible [\v!text] [tmapsto] ["21A6]
\definemathextensible [\v!text] [thookleftarrow] ["21A9]
\definemathextensible [\v!text] [thookrightarrow] ["21AA]
\definemathextensible [\v!text] [tleftharpoondown] ["21BD]
@@ -782,59 +642,30 @@
\definemathextensible [\v!text] [tleftrightharpoons] ["21CB]
\definemathextensible [\v!text] [trightleftharpoons] ["21CC]
\definemathextensible [\v!text] [ttriplerel] ["2261]
+\definemathextensible [\v!text] [tleftrightarrow] ["27F7]
+\definemathextensible [\v!text] [tLeftarrow] ["27F8]
+\definemathextensible [\v!text] [tRightarrow] ["27F9]
+\definemathextensible [\v!text] [tLeftrightarrow] ["27FA]
-\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] [overleftarrow] ["2190]
+\definemathoverextensible [\v!top] [overrightarrow] ["2192]
\definemathoverextensible [\v!top] [overleftharpoondown] ["21BD]
\definemathoverextensible [\v!top] [overleftharpoonup] ["21BC]
\definemathoverextensible [\v!top] [overrightharpoondown] ["21C1]
\definemathoverextensible [\v!top] [overrightharpoonup] ["21C0]
+\definemathoverextensible [\v!top] [overleftrightarrow] ["27F7]
+\definemathoverextensible [\v!top] [overtwoheadleftarrow] ["27F8]
+\definemathoverextensible [\v!top] [overtwoheadrightarrow] ["27F9]
-\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] [underleftarrow] ["2190]
+\definemathunderextensible [\v!bottom] [underrightarrow] ["2192]
\definemathunderextensible [\v!bottom] [underleftharpoondown] ["21BD]
\definemathunderextensible [\v!bottom] [underleftharpoonup] ["21BC]
\definemathunderextensible [\v!bottom] [underrightharpoondown] ["21C1]
\definemathunderextensible [\v!bottom] [underrightharpoonup] ["21C0]
-
-% 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.
-%
-% 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*
-
-\definemathoverextensible [vfenced] [overbar] ["FE33E] % ["203E]
-\definemathunderextensible [vfenced] [underbar] ["FE33F] % ["203E]
-\definemathdoubleextensible [vfenced] [doublebar] ["FE33E] ["FE33F]
-
-\definemathoverextensible [vfenced] [overbrace] ["FE3DE] % ["023DE]
-\definemathunderextensible [vfenced] [underbrace] ["FE3DF] % ["023DF]
-\definemathdoubleextensible [vfenced] [doublebrace] ["FE3DE] ["FE3DF]
-
-\definemathoverextensible [vfenced] [overparent] ["FE3DC] % ["023DC]
-\definemathunderextensible [vfenced] [underparent] ["FE3DD] % ["023DD]
-\definemathdoubleextensible [vfenced] [doubleparent] ["FE3DC] ["FE3DD]
-
-\definemathoverextensible [vfenced] [overbracket] ["FE3B4] % ["023B4]
-\definemathunderextensible [vfenced] [underbracket] ["FE3B5] % ["023B5]
-\definemathdoubleextensible [vfenced] [doublebracket] ["FE3B4] ["FE3B5]
-
-% \unexpanded\def\mathopwithlimits#1#2{\mathop{#1{#2}}\limits}
+\definemathunderextensible [\v!bottom] [underleftrightarrow] ["27F7]
+\definemathunderextensible [\v!bottom] [undertwoheadleftarrow] ["27F8]
+\definemathunderextensible [\v!bottom] [undertwoheadrightarrow] ["27F9]
%D Some bonus ones (for the moment here):
@@ -865,7 +696,7 @@
#3%
\endgroup}}
-% These will be defined in char-def as well once we have \leaders
+% These will be defined in char-def as well:
\unexpanded\def\rightarrowfill {\math_stackers_hacked_fill \relbar \relbar \rightarrow}
\unexpanded\def\leftarrowfill {\math_stackers_hacked_fill \leftarrow \relbar \relbar }
@@ -903,7 +734,6 @@
{\expandafter\let\csname\??mathextensiblefallbacks\number#2\expandafter\endcsname\csname#1\endcsname
\expandafter\let\csname #1\expandafter\endcsname\csname#1\endcsname}
-\defineextensiblefiller [barfill] ["203E]
\defineextensiblefiller [relfill] ["002D]
\defineextensiblefiller [equalfill] ["003D]
\defineextensiblefiller [leftarrowfill] ["2190]
@@ -925,7 +755,6 @@
\defineextensiblefiller [Leftarrowfill] ["27F8]
\defineextensiblefiller [Rightarrowfill] ["27F9]
\defineextensiblefiller [Leftrightarrowfill] ["27FA]
-\defineextensiblefiller [Leftrightarrowfill] ["27FA]
%D Extra:
@@ -937,40 +766,6 @@
% \mathchardef\doublebond"003D
% \mathchardef\triplebond"2261
-%D Also handy:
-
-\unexpanded\def\definemathunstacked
- {\dotripleempty\math_stackers_define_unstacked_normal}
-
-\def\math_stackers_define_unstacked_normal[#1][#2][#3]% category name unicode
- {\ifthirdargument
- \setuevalue{#2}{\math_stackers_unstacked_normal{#1}{\number#3}}%
- \else
- \setuevalue{#1}{\math_stackers_unstacked_normal\noexpand\currentmathstackers{\number#2}}%
- \fi}
-
-\unexpanded\def\math_stackers_unstacked_normal#category#codepoint%
- {\begingroup
- \edef\currentmathstackers{#category}%
- \edef\p_moffset{\mathstackersparameter\c!moffset}%
- \ifx\p_moffset\empty \else
- \mskip\scratchmuskip
- \fi
- \ifmmode\math_class_by_parameter\mathstackersparameter\else\dontleavehmode\fi
- {\usemathstackerscolorparameter\c!color
- \Umathchar\zerocount\defaultmathfamily#codepoint}%
- \ifx\p_moffset\empty \else
- \mskip\scratchmuskip
- \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\;}
-
\protect \endinput
% \mathrel{\mathop{\hbox to \dimen0{\hss\copy4\hss}}
diff --git a/tex/context/base/math-vfu.lua b/tex/context/base/math-vfu.lua
index 6d9a9f903..2f7c0507b 100644
--- a/tex/context/base/math-vfu.lua
+++ b/tex/context/base/math-vfu.lua
@@ -26,7 +26,6 @@ local type, next = type, next
local max = math.max
local format = string.format
local utfchar = utf.char
-local fastcopy = table.copy
local fonts, nodes, mathematics = fonts, nodes, mathematics
@@ -39,7 +38,6 @@ local report_virtual = logs.reporter("fonts","virtual math")
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
-local formatters = string.formatters
local mathencodings = allocate()
fonts.encodings.math = mathencodings -- better is then: fonts.encodings.vectors
@@ -201,44 +199,21 @@ end
-- { "node", nodeinjections.transform(.7,0,0,.7) },
-- commands[#commands+1] = { "node", nodeinjections.restore() }
--- local done = { }
---
--- local function raise(main,characters,id,size,unicode,private,n,id_of_smaller) -- this is a real fake mess
--- local raised = characters[private]
--- if raised then
--- if not done[unicode] then
--- report_virtual("temporary too large %U due to issues in luatex backend",unicode)
--- done[unicode] = true
--- end
--- local up = 0.85 * main.parameters.x_height
--- local slot = { "slot", id, private }
--- local commands = {
--- push,
--- { "down", - up },
--- -- { "scale", .7, 0, 0, .7 },
--- slot,
--- }
--- for i=2,n do
--- commands[#commands+1] = slot
--- end
--- commands[#commands+1] = pop
--- characters[unicode] = {
--- width = .7 * n * raised.width,
--- height = .7 * (raised.height + up),
--- depth = .7 * (raised.depth - up),
--- commands = commands,
--- }
--- end
--- end
+local done = { }
-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]
+local function raise(main,characters,id,size,unicode,private,n) -- this is a real fake mess
+ local raised = characters[private]
if raised then
+ if not done[unicode] then
+ report_virtual("temporary too large %U due to issues in luatex backend",unicode)
+ done[unicode] = true
+ end
local up = 0.85 * main.parameters.x_height
- local slot = { "slot", id_of_smaller, private }
+ local slot = { "slot", id, private }
local commands = {
push,
{ "down", - up },
+ -- { "scale", .7, 0, 0, .7 },
slot,
}
for i=2,n do
@@ -246,10 +221,9 @@ local function raise(main,characters,id,size,unicode,private,n,id_of_smaller) --
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,
+ width = .7 * n * raised.width,
+ height = .7 * (raised.height + up),
+ depth = .7 * (raised.depth - up),
commands = commands,
}
end
@@ -432,25 +406,7 @@ local function repeated(main,characters,id,size,unicode,u,n,private,fraction) --
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 { }
@@ -548,11 +504,9 @@ function vfmath.addmissing(main,id,size)
repeated(main,characters,id,size,0x222C,0x222B,2,0xFF800,1/3)
repeated(main,characters,id,size,0x222D,0x222B,3,0xFF810,1/3)
- characters[0xFE325] = fastcopy(characters[0x2032])
-
- raise (main,characters,id,size,0x02032,0xFE325,1,id_of_smaller) -- prime
- raise (main,characters,id,size,0x02033,0xFE325,2,id_of_smaller) -- double prime
- raise (main,characters,id,size,0x02034,0xFE325,3,id_of_smaller) -- triple prime
+ -- raise (main,characters,id,size,0x02032,0xFE325,1) -- prime
+ -- raise (main,characters,id,size,0x02033,0xFE325,2) -- double prime
+ -- raise (main,characters,id,size,0x02034,0xFE325,3) -- triple prime
-- there are more (needs discussion first):
@@ -561,9 +515,6 @@ function vfmath.addmissing(main,id,size)
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
@@ -583,82 +534,6 @@ setmetatableindex(reverse, function(t,name)
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,
- commands = { { "slot", slot, unicode } },
- }
- local glyphdata = newdata
- local nextglyph = olddata.next
- while nextglyph do
- local oldnextdata = original[nextglyph]
- local newnextdata = {
- commands = { { "slot", slot, nextglyph } },
- width = oldnextdata.width,
- height = oldnextdata.height,
- depth = oldnextdata.depth,
- }
- local newnextglyph = addprivate(main,formatters["M-N-%H"](nextglyph),newnextdata)
- newdata.next = newnextglyph
--- report_virtual("copied next: %X",newdata.next)
- local nextnextglyph = oldnextdata.next
- if nextnextglyph == nextglyph then
- break
- else
- olddata = oldnextdata
- newdata = newnextdata
- nextglyph = nextnextglyph
- 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 = {
- commands = { { "slot", slot, oldglyph } },
- width = olddata.width,
- height = olddata.height,
- depth = olddata.depth,
- }
- hvi.glyph = addprivate(main,formatters["M-H-%H"](oldglyph),newdata)
--- report_virtual("copied h variant: %X at index %i",hvi.glyph,i)
- 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 = {
- commands = { { "slot", slot, oldglyph } },
- width = olddata.width,
- height = olddata.height,
- depth = olddata.depth,
- }
- vvi.glyph = addprivate(main,formatters["M-V-%H"](oldglyph),newdata)
--- report_virtual("copied v variant: %X at index %i",vvi.glyph,i)
- end
- end
- return newdata
- end
-end
-
-vfmath.copy_glyph = copy_glyph
-
function vfmath.define(specification,set,goodies)
local name = specification.name -- symbolic name
local size = specification.size -- given size
@@ -701,7 +576,7 @@ function vfmath.define(specification,set,goodies)
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)
+ report_virtual("loading font %a subfont %s with name %a at %p as id %s using encoding %p",name,s,ssname,size,id,ss.vector)
end
if not ss.checked then
ss.checked = true
@@ -802,7 +677,6 @@ function vfmath.define(specification,set,goodies)
parameters.x_height = parameters.x_height or 0
--
local already_reported = false
- local parameters_done = false
for s=1,n do
local ss, fs = okset[s], loaded[s]
if not fs then
@@ -811,13 +685,7 @@ function vfmath.define(specification,set,goodies)
-- 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
+ if 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
@@ -848,202 +716,187 @@ function vfmath.define(specification,set,goodies)
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
- local vector = mathencodings[vectorname]
- local rotcev = reverse[vectorname]
- local isextension = ss.extension
- if vector and rotcev then
- local fc, fd, si = fs.characters, fs.descriptions, shared[s]
- 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]
- if not rv then rv = { } rf[vectorname] = rv end
- local ru = rv[unicode]
- if not ru then
- if trace_virtual then
- report_virtual("unicode slot %U has no index %H in vector %a for font %a",unicode,index,vectorname,fontname)
- elseif not already_reported then
- report_virtual("the mapping is incomplete for %a at %p",name,size)
- already_reported = true
+ local vectorname = ss.vector
+ if vectorname then
+ local offset = 0xFF000
+ local vector = mathencodings[vectorname]
+ local rotcev = reverse[vectorname]
+ local isextension = ss.extension
+ if vector and rotcev then
+ local fc, fd, si = fs.characters, fs.descriptions, shared[s]
+ 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]
+ if not rv then rv = { } rf[vectorname] = rv end
+ local ru = rv[unicode]
+ if not ru then
+ if trace_virtual then
+ report_virtual("unicode slot %U has no index %H in vector %a for font %a",unicode,index,vectorname,fontname)
+ 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 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
- rv[unicode] = true
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 kerns = fci.kerns
- local width = fci.width
local italic = fci.italic
- 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
+ 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
- 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
+ local hv = fci.horiz_variants
+ if hv then
+ t.horiz_variants = hv
end
- if not next(krn) then
- krn = nil
+ 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 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
+ 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
- characters[unicode] = t
- else
- characters[unicode] = {
- width = width,
- height = fci.height,
- depth = fci.depth,
- italic = italic,
- commands = ref,
- }
end
+ characters[offset + index] = t
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
+ 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 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
+ 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
- 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
+ characters[unicode] = {
+ width = fci.width,
+ height = fci.height,
+ depth = fci.depth,
+ italic = fci.italic,
+ commands = ref,
+ next = offset + index,
+ }
end
end
end
end
- else
- report_virtual("error in loading %a, problematic vector %a",name,vectorname)
end
+ else
+ report_virtual("error in loading %a, problematic vector %a",name,vectorname)
end
end
mathematics.extras.copy(main) --not needed here (yet)
diff --git a/tex/context/base/meta-fig.mkiv b/tex/context/base/meta-fig.mkiv
index 46dc4cffc..7fbc33be9 100644
--- a/tex/context/base/meta-fig.mkiv
+++ b/tex/context/base/meta-fig.mkiv
@@ -54,7 +54,7 @@
\unexpanded\def\MPfigure#1#2% test for dup figure, can be replaced by a textext
{\bgroup
- \getfiguredimensions[#1]% [\c!object=\v!no] already set
+ \getfiguredimensionsonly[#1]% [\c!object=\v!no] already set
\startMPcode
externalfigure "#1"
xscaled \the\dimexpr\figurewidth \relax\space % must be points
diff --git a/tex/context/base/meta-fnt.lua b/tex/context/base/meta-fnt.lua
deleted file mode 100644
index 3d13b0b34..000000000
--- a/tex/context/base/meta-fnt.lua
+++ /dev/null
@@ -1,265 +0,0 @@
-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"
-}
-
-local concat = table.concat
-local format = string.format
-local formatters = string.formatters
-local chardata = characters.data
-local fontdata = fonts.hashes.identifiers
-
-local vffonts = fonts.handlers.vf
-
-local mpfonts = fonts.mp or { }
-fonts.mp = mpfonts
-
-mpfonts.version = mpfonts.version or 1.20
-mpfonts.inline = true
-mpfonts.cache = containers.define("fonts", "mp", mpfonts.version, true)
-
-metapost.fonts = metapost.fonts or { }
-
--- a few glocals
-
-local characters, descriptions = { }, { }
-local factor, code, slot, width, height, depth, total, variants, bbox, llx, lly, urx, ury = 100, { }, 0, 0, 0, 0, 0, 0, true, 0, 0, 0, 0
-
--- The next variant of ActualText is what Taco and I could come up with
--- eventually. As of September 2013 Acrobat copies okay, Summatra 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)
-
-local function topdf(n,code)
- if n < 0x10000 then
- return formatters["BT /Span << /ActualText >> BDC [] TJ % t EMC ET"](n,code)
- else
- return formatters["BT /Span << /ActualText >> BDC [] TJ % t EMC ET"](n/1024+0xD800,n%1024+0xDC00,code)
- end
-end
-
--- local function topdf(n,code)
--- return formatters["/Span << /ActualText (CTX) >> BDC % t EMC"](code)
--- end
-
-local flusher = {
- startfigure = function(_chr_,_llx_,_lly_,_urx_,_ury_)
- code = { }
- slot = _chr_
- llx = _llx_
- lly = _lly_
- urx = _urx_
- ury = _ury_
- width = urx - llx
- height = ury
- depth = -lly
- total = total + 1
- inline = mpfonts.inline
- end,
- flushfigure = function(t)
- for i=1,#t do
- code[#code+1] = t[i]
- end
- end,
- stopfigure = function()
- local cd = chardata[n]
- descriptions[slot] = {
- -- unicode = slot,
- name = cd and cd.adobename,
- width = width * 100,
- height = height * 100,
- depth = depth * 100,
- boundingbox = { llx, lly, urx, ury },
- }
- if inline then
- characters[slot] = {
- commands = {
- { "special", "pdf: " .. topdf(slot,code) },
- }
- }
- else
- characters[slot] = {
- commands = {
- {
- "image",
- {
- stream = topdf(slot,code),
- bbox = { 0, -depth * 65536, width * 65536, height * 65536 }
- },
- },
- }
- }
- end
- end
-}
-
-local function process(mpxformat,name,instances,scalefactor)
- local filename = resolvers.findfile(name)
- local attributes = filename and lfs.isfile(filename) and lfs.attributes(filename)
- if attributes then
- statistics.starttiming(metapost.fonts)
- scalefactor = scalefactor or 1
- instances = instances or metapost.fonts.instances or 1 -- maybe store in liost too
- 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 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)
- local data = io.loaddata(filename)
- metapost.reset(mpxformat)
- metapost.setoutercolor(2) -- no outer color and no reset either
- lists = { }
- for i=1,instances do
- characters = { }
- descriptions = { }
- metapost.process(
- mpxformat,
- {
- formatters["randomseed := %s ;"](i*10),
- formatters["charscale := %s ;"](scalefactor),
- data,
- },
- false,
- flusher,
- false,
- false,
- "all"
- )
- lists[i] = {
- characters = characters,
- descriptions = descriptions,
- parameters = {
- designsize = 655360,
- slant = 0,
- space = 333 * scalefactor,
- space_stretch = 166.5 * scalefactor,
- space_shrink = 111 * scalefactor,
- x_height = 431 * scalefactor,
- quad = 1000 * scalefactor,
- extra_space = 0,
- },
- properties = {
- name = formatters["%s-%03i"](hash,i),
- virtualized = true,
- spacer = "space",
- }
- }
- end
- lists.version = metapost.variables.fontversion or "1.000"
- lists.modification = modification
- lists.filesize = filesize
- lists.instances = instances
- lists.scalefactor = scalefactor
- metapost.reset(mpxformat) -- saves memory
- lists = containers.write(mpfonts.cache, hash, lists)
- statistics.stoptiming(flusher)
- end
- variants = variants + #lists
- statistics.stoptiming(metapost.fonts)
- return lists
- else
- return { }
- end
-end
-
-metapost.fonts.flusher = flusher
-metapost.fonts.instances = 1
-metapost.fonts.process = process
-
-local function build(g,v)
- local size = g.specification.size
- local data = process(v[2],v[3],v[4],size/655360,v[6])
- local list = { }
- local t = { }
- for d=1,#data do
- t = fonts.constructors.scale(data[d],-1000)
- local id = font.nextid()
- t.fonts = { { id = id } }
- fontdata[id] = t
- if v[5] then
- vffonts.helpers.composecharacters(t)
- end
- list[d] = font.define(t)
- end
- for k, v in next, t do -- last t
- g[k] = v -- kind of replace, when not present, make nil
- end
- g.properties.virtualized = true
- g.variants = list
-end
-
-vffonts.combiner.commands.metapost = build
-vffonts.combiner.commands.metafont = build
-
-statistics.register("metapost font generation", function()
- local time = statistics.elapsedtime(flusher)
- if total > 0 then
- return format("%i glyphs, %.3f seconds runtime, %i glyphs/second", total, time, total/time)
- else
- return format("%i glyphs, %.3f seconds runtime", total, time)
- end
-end)
-
-statistics.register("metapost font loading",function()
- local time = statistics.elapsedtime(metapost.fonts)
- if variants > 0 then
- return format("%.3f seconds, %i instances, %0.3f instances/second", time, variants, variants/time)
- else
- return format("%.3f seconds, %i instances", time, variants)
- end
-end)
-
--- fonts.definers.methods.install( "bidi", {
--- {
--- "metapost", -- method
--- "metafun", -- format
--- "fontoeps.mp", -- filename
--- 1, -- instances
--- false, -- compose
--- },
--- } )
-
-local report = logs.reporter("metapost","fonts")
-
-function metapost.fonts.define(specification)
- local fontname = specification.fontname or ""
- local filename = specification.filename or ""
- local format = specification.format or "metafun"
- if fontname == "" then
- report("no fontname given")
- return
- end
- if filename == "" then
- report("no filename given for %a",fontname)
- return
- end
- local fullname = resolvers.findfile(filename)
- if fullname == "" then
- report("unable to locate file %a",filename)
- return
- end
- report("generating font %a using format %a and file %a",fontname,format,filename)
- fonts.definers.methods.install(fontname, {
- {
- specification.engine or "metapost",
- format,
- filename,
- specification.instances or 1,
- specification.compose or false,
- },
- } )
-end
-
-commands.definemetafont = metapost.fonts.define
-
--- metapost.fonts.define {
--- fontname = "bidi",
--- filename = "bidi-symbols.mp",
--- }
diff --git a/tex/context/base/meta-fnt.mkiv b/tex/context/base/meta-fnt.mkiv
deleted file mode 100644
index 603fcf14d..000000000
--- a/tex/context/base/meta-fnt.mkiv
+++ /dev/null
@@ -1,36 +0,0 @@
-%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}{1.001}
-
-\unprotect
-
-\unexpanded\def\definemetafont
- {\dotripleempty\meta_font_define}
-
-\def\meta_font_define[#1][#2][#3]%
- {\ctxcommand{definemetafont {
- fontname = "#1",
- filename = "#2"
- % no #3 settings yet (compose, instances)
- }}}
-
-% \startluacode
-% metapost.fonts.define { fontname = "bidi-symbols", filename = "bidi-symbols.mp" }
-% \stopluacode
-
-% \definemetafont[bidi-symbols][bidi-symbols.mp]
-
-\protect \endinput
diff --git a/tex/context/base/meta-imp-txt.mkiv b/tex/context/base/meta-imp-txt.mkiv
index bcfc5513f..3a9ad5927 100644
--- a/tex/context/base/meta-imp-txt.mkiv
+++ b/tex/context/base/meta-imp-txt.mkiv
@@ -170,12 +170,12 @@
% we default to nothing
\stopuseMPgraphic
-\unexpanded\def\dofollowtokens#1#2%
+\unexpanded\def\followtokens#1%
{\vbox\bgroup
\forgetall
\dontcomplain
\startMPenvironment
- \doifundefined{RotFont}{\definefont[RotFont][RegularBold]}%
+ \doifundefined{RotFont}{\definefont[RotFont][RegularBold]}
\stopMPenvironment
\MPtoks\emptytoks
\resetMPdrawing
@@ -183,13 +183,13 @@
\includeMPgraphic{followtokens} ;
picture pic[] ; numeric len[], n ; n := 0 ;
\stopMPdrawing
- \handletokens#2\with\processfollowingtoken
+ \handletokens#1\with\processfollowingtoken
\startMPdrawing
if unknown RotPath : path RotPath ; RotPath := origin ; fi ;
if unknown RotColor : color RotColor ; RotColor := black ; fi ;
if unknown TraceRot : boolean TraceRot ; TraceRot := false ; fi ;
if unknown ExtraRot : numeric ExtraRot ; ExtraRot := 0 ; fi ;
- numeric al, at, pl, pc, wid, pos ; pair ap, ad ;
+ numeric al, at, pl, wid, pos ; pair ap, ad ;
al := arclength RotPath ;
if al=0 :
al := len[n] + ExtraRot ;
@@ -199,19 +199,13 @@
RotPath := RotPath scaled ((len[n]+ExtraRot)/al) ;
al := arclength RotPath ;
fi ;
- if \number#1 = 1 :
- pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
- pc := 0 ;
- else : % centered / MP
- pl := 0 ;
- pc := arclength RotPath/2 - len[n]/2 ;
- fi ;
+ pl := (al-len[n])/(if n>1 : (n-1) else : 1 fi) ;
if TraceRot :
draw RotPath withpen pencircle scaled 1pt withcolor blue ;
fi ;
for i=1 upto n :
wid := abs(xpart urcorner pic[i] - xpart llcorner pic[i]) ;
- pos := len[i]-wid/2 + (i-1)*pl + pc ;
+ pos := len[i]-wid/2 + (i-1)*pl ;
at := arctime pos of RotPath ;
ap := point at of RotPath ;
ad := direction at of RotPath ;
@@ -231,11 +225,6 @@
\resetMPdrawing
\egroup}
-\unexpanded\def\followtokens {\dofollowtokens1}
-\unexpanded\def\followtokenscentered{\dofollowtokens0}
-
-% stretched variant:
-%
% \followtokens
% {This is just a dummy text, kerned by T{\kern
% -.1667em\lower .5ex\hbox {E}}{\kern -.125emX} and typeset
@@ -243,27 +232,6 @@
% E}{\setMFPfont T}{\setMFPfont A}{\setMFPfont
% P}{\setMFPfont O}{\setMFPfont S}{\setMFPfont T}.\quad}
-% centered variant:
-%
-% \def\followtokengraphicscale#1{%%
-% \startuseMPgraphic {followtokens}
-% path RotPath; RotPath := reverse halfcircle scaled #1 ;
-% draw RotPath ;
-% setbounds currentpicture to boundingbox fullcircle scaled 12cm ;
-% \stopuseMPgraphic}
-%
-% \startoverlay
-% {\followtokengraphicscale{12cm}%%
-% \followtokenscentered{There was question on the list about this kind of graphics.}}
-% {\followtokengraphicscale{10cm}%%
-% \followtokenscentered{And Marco patched followingtokens to handle a centered text.}}
-% {\followtokengraphicscale{8cm}%%
-% \followtokenscentered{That ended up as variant branch in the main macro.}}
-% {\followtokengraphicscale{6cm}%%
-% \followtokenscentered{So now we have two commands.}}
-% \stopoverlay
-
-
\startuseMPgraphic{fuzzycount}
begingroup
save height, span, drift, d, cp ;
diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv
index 32f72cfe6..6502047fb 100644
--- a/tex/context/base/meta-ini.mkiv
+++ b/tex/context/base/meta-ini.mkiv
@@ -429,19 +429,16 @@
\hskip\cldcontext{fonts.hashes.parameters[font.current()].designsize}sp\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;
+ defaultfont:="\truefontname{Regular}";
+ defaultscale:=\the\bodyfontsize/10pt;
\stopMPinitializations
% watch out, this is a type1 font because mp can only handle 8 bit fonts
-% \startMPinitializations % scale is not yet ok
-% defaultfont:="rm-lmtt10";
-% \stopMPinitializations
+\startMPinitializations % scale is not yet ok
+ defaultfont:="rm-lmtt10";
+\stopMPinitializations
%D A signal that we're in combined \CONTEXT||\METAFUN mode:
@@ -596,7 +593,7 @@
%D \stoptyping
\def\overlaystamp % watch the \MPcolor, since colors can be redefined
- {\overlaywidth:\overlayheight:\overlaydepth:\overlayoffset:\overlaylinewidth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
+ {\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
%D A better approach is to let additional variables play a role
%D in determining the uniqueness. In the next macro, the
@@ -1097,9 +1094,8 @@
CurrentLayout:="\currentlayout";
OverlayWidth:=\overlaywidth;
OverlayHeight:=\overlayheight;
- OverlayDepth:=\overlaydepth;
+ OverlayDepth:=\overlayheight;
OverlayLineWidth:=\overlaylinewidth;
- OverlayOffset:=\overlayoffset;
%
\m_meta_colo_initializations
%
@@ -1364,67 +1360,6 @@
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{\ctxcommand{mprunvar("#1")}} \let\mprunvar\MPrunvar
-\def\MPruntab#1#2{\ctxcommand{mprunvar("#1",\number#2)}} \let\mpruntab\MPruntab
-\def\MPrunset#1#2{\ctxcommand{mprunvar("#1","#2")}} \let\mprunset\MPrunset
-
-%D We also provide an outputless run:
-
-\unexpanded\def\startMPcalculation
- {\begingroup
- \setbox\nextbox\hbox\bgroup
- \dosinglegroupempty\meta_start_calculation}
-
-\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}
-
-\let\stopMPcalculation\relax
-
%D \macros
%D {setupMPgraphics}
%D
diff --git a/tex/context/base/meta-pag.mkiv b/tex/context/base/meta-pag.mkiv
index a25353b18..7124902e7 100644
--- a/tex/context/base/meta-pag.mkiv
+++ b/tex/context/base/meta-pag.mkiv
@@ -41,7 +41,7 @@
% maybe always set as frozen anyway
\startMPinitializations
- % def LoadPageState =
+ def LoadPageState =
OnRightPage:=\MPonrightpage;
OnOddPage:=\MPonoddpage;
RealPageNumber:=\the\realpageno;
@@ -88,8 +88,6 @@
LayoutColumns:=\the\layoutcolumns;
LayoutColumnDistance:=\the\layoutcolumndistance;
LayoutColumnWidth:=\the\layoutcolumnwidth;
- def LoadPageState =
- % now always set .. this dummy can move to the mp code
enddef;
\stopMPinitializations
diff --git a/tex/context/base/meta-pdf.lua b/tex/context/base/meta-pdf.lua
index c49ad92ae..e51290e42 100644
--- a/tex/context/base/meta-pdf.lua
+++ b/tex/context/base/meta-pdf.lua
@@ -23,8 +23,6 @@ local report_mptopdf = logs.reporter("graphics","mptopdf")
local mplib, metapost, lpdf, context = mplib, metapost, lpdf, context
-local texgetattribute = tex.getattribute
-
local pdfrgbcode = lpdf.rgbcode
local pdfcmykcode = lpdf.cmykcode
local pdfgraycode = lpdf.graycode
@@ -86,7 +84,7 @@ end
local function flushconcat()
if m_stack_concat then
- mpscode(f_concat(unpack(m_stack_concat)))
+ mpscode(f_concatm(unpack(m_stack_concat)))
m_stack_concat = nil
end
end
@@ -541,7 +539,7 @@ function mptopdf.convertmpstopdf(name)
resetall()
local ok, m_data, n = resolvers.loadbinfile(name, 'tex') -- we need a binary load !
if ok then
- mps.colormodel = texgetattribute(a_colorspace)
+ mps.colormodel = tex.attribute[a_colorspace]
statistics.starttiming(mptopdf)
mptopdf.nofconverted = mptopdf.nofconverted + 1
pdfcode(formatters["\\letterpercent\\space mptopdf begin: n=%s, file=%s"](mptopdf.nofconverted,file.basename(name)))
diff --git a/tex/context/base/meta-pdf.mkiv b/tex/context/base/meta-pdf.mkiv
index 3469419d4..a8fdaff42 100644
--- a/tex/context/base/meta-pdf.mkiv
+++ b/tex/context/base/meta-pdf.mkiv
@@ -37,7 +37,7 @@
\def\PDFMPformoffset{\ifdefined\objectoffset\objectoffset\else\zeropoint\fi} % obsolete, will go
-\unexpanded\def\convertMPtoPDF#1#2#3% scaling no longer supported at this level (so #2 & #3 are ignored)
+\def\convertMPtoPDF#1#2#3% scaling no longer supported at this level (so #2 & #3 are ignored)
{\dostarttagged\t!mpgraphic\empty
\naturalvbox attr \imageattribute 1 \bgroup
\message{[MP to PDF]}%
diff --git a/tex/context/base/mlib-ctx.lua b/tex/context/base/mlib-ctx.lua
index a1a4e645a..04e0efcb4 100644
--- a/tex/context/base/mlib-ctx.lua
+++ b/tex/context/base/mlib-ctx.lua
@@ -43,7 +43,6 @@ local function setmpsformat(specification)
specification.method = method
end
specification.mpx = metapost.format(instance,format,method)
- return specification
end
local extensiondata = metapost.extensiondata or storage.allocate { }
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index d5f22cd7e..963309951 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -10,9 +10,8 @@ if not modules then modules = { } end modules ['mlib-pdf'] = {
local format, concat, gsub = string.format, table.concat, string.gsub
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 setmetatable = setmetatable
+local Cf, C, Cg, Ct, P, S, lpegmatch = lpeg.Cf, lpeg.C, lpeg.Cg, lpeg.Ct, lpeg.P, lpeg.S, lpeg.match
local formatters = string.formatters
local report_metapost = logs.reporter("metapost")
@@ -31,12 +30,13 @@ metapost.flushers = metapost.flushers or { }
local pdfflusher = { }
metapost.flushers.pdf = pdfflusher
-metapost.multipass = false -- to be stacked
+metapost.multipass = false
metapost.n = 0
-metapost.optimize = true -- false
+metapost.optimize = true -- false
local experiment = true -- uses context(node) that already does delayed nodes
-local savedliterals = nil -- needs checking
+
+local savedliterals = nil -- needs checking
local mpsliteral = nodes.pool.register(node.new("whatsit",nodes.whatsitcodes.pdfliteral)) -- pdfliteral.mode = 1
local pdfliteral = function(s)
@@ -268,48 +268,7 @@ metapost.flushnormalpath = flushnormalpath
-- performance penalty, but so is passing extra arguments (result, flusher, after)
-- and returning stuff.
-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 variable =
- lpeg.P("1:") * key * number
- + lpeg.P("2:") * key * C((1-newline)^0)
- + lpeg.P("3:") * key * (P("false") * Cc(false) + P("true") * Cc(true))
- + lpeg.S("4568") * P(":") * key * Ct(number^1)
- + lpeg.P("7:") * key * Ct(Ct(number * number^-5)^1)
-
-local pattern = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset)
-
-metapost.variables = { } -- to be stacked
-metapost.llx = 0 -- to be stacked
-metapost.lly = 0 -- to be stacked
-metapost.urx = 0 -- to be stacked
-metapost.ury = 0 -- to be stacked
-
-function commands.mprunvar(key,n)
- local value = metapost.variables[key]
- if value ~= nil then
- local tvalue = type(value)
- if tvalue == "table" then
- local ntype = type(n)
- if ntype == "number" then
- context(value[n])
- elseif ntype == "string" then
- context(concat(value,n))
- else
- context(concat(value," "))
- end
- elseif tvalue == "number" or tvalue == "boolean" then
- context(tostring(value))
- elseif tvalue == "string" then
- context(value)
- end
- end
-end
+local function ignore() end
function metapost.flush(result,flusher,askedfig)
if result then
@@ -324,29 +283,15 @@ function metapost.flush(result,flusher,askedfig)
local stopfigure = flusher.stopfigure
local flushfigure = flusher.flushfigure
local textfigure = flusher.textfigure
- for f=1,#figures do
+ for f=1, #figures do
local figure = figures[f]
local objects = getobjects(result,figure,f)
- local fignum = figure:charcode() or 0
+ local fignum = figure:charcode() or 0
if askedfig == "direct" or askedfig == "all" or askedfig == fignum then
local t = { }
local miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
local bbox = figure:boundingbox()
local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4]
- local variables = { }
- metapost.variables = variables
- metapost.properties = {
- llx = llx,
- lly = lly,
- urx = urx,
- ury = ury,
- slot = figure:charcode(),
- width = figure:width(),
- height = figure:height(),
- depth = figure:depth(),
- italic = figure:italcorr(),
- }
- -- replaced by the above
metapost.llx = llx
metapost.lly = lly
metapost.urx = urx
@@ -363,10 +308,8 @@ function metapost.flush(result,flusher,askedfig)
for o=1,#objects do
local object = objects[o]
local objecttype = object.type
- if objecttype == "start_bounds" or objecttype == "stop_bounds" then
+ if objecttype == "start_bounds" or objecttype == "stop_bounds" or objecttype == "special" then
-- skip
- elseif objecttype == "special" then
- lpegmatch(pattern,object.prescript,1,variables)
elseif objecttype == "start_clip" then
t[#t+1] = "q"
flushnormalpath(object.path,t,false)
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 9f6cedad1..93bddc2dd 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -6,20 +6,20 @@ if not modules then modules = { } end modules ['mlib-pps'] = {
license = "see context related readme files",
}
--- todo: pass multipass nicer
+-- todo: make a hashed textext variant where we only process the text once (normally
+-- we cannot assume that no macros are involved which influence a next textext
local format, gmatch, match, split = string.format, string.gmatch, string.match, string.split
local tonumber, type = tonumber, type
local round = math.round
-local insert, remove, concat = table.insert, table.remove, table.concat
+local insert, concat = table.insert, 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 = lpeg.match
local formatters = string.formatters
local mplib, metapost, lpdf, context = mplib, metapost, lpdf, context
-local texgetbox = tex.getbox
-local texsetbox = tex.setbox
+local texbox = tex.box
local copy_list = node.copy_list
local free_list = node.flush_list
local setmetatableindex = table.setmetatableindex
@@ -211,65 +211,52 @@ local function checkandconvert(ca,cb)
end
end
-local stack = { } -- quick hack, we will pass topofstack around
-local top = nil
-local nofruns = 0 -- askedfig: "all", "first", number
+local current_format, current_graphic, current_initializations
-local function startjob(texmode)
- top = {
- textexts = { }, -- all boxes, optionally with a different color
- texslots = { }, -- references to textexts in order or usage
- texorder = { }, -- references to textexts by mp index
- textrial = 0,
- texfinal = 0,
- -- used by tx plugin
- texhash = { },
- texlast = 0,
- texmode = texmode, -- some day we can then skip all pre/postscripts
- }
- insert(stack,top)
- if trace_runs then
- report_metapost("starting run at level %i",#stack)
- end
- return top
-end
+metapost.multipass = false
+
+local textexts = { } -- all boxes, optionally with a different color
+local texslots = { } -- references to textexts in order or usage
+local texorder = { } -- references to textexts by mp index
+local textrial = 0
+local texfinal = 0
+local scratchbox = 0
-local function stopjob()
- if top then
- for n, tn in next, top.textexts do
+local function freeboxes()
+ for n, box in next, textexts do
+ local tn = textexts[n]
+ if tn then
free_list(tn)
+ -- texbox[scratchbox] = tn
+ -- texbox[scratchbox] = nil -- this frees too
if trace_textexts then
report_textexts("freeing box %s",n)
end
end
- if trace_runs then
- report_metapost("stopping run at level %i",#stack)
- end
- remove(stack)
- top = stack[#stack]
- return top
end
+ textexts = { }
+ texslots = { }
+ texorder = { }
+ textrial = 0
+ texfinal = 0
end
-function metapost.settextexts () end -- obsolete
-function metapost.resettextexts() end -- obsolete
-
--- end of new
+metapost.resettextexts = freeboxes
function metapost.settext(box,slot)
- top.textexts[slot] = copy_list(texgetbox(box))
- texsetbox(box,nil)
+ textexts[slot] = copy_list(texbox[box])
+ texbox[box] = nil
-- this will become
- -- top.textexts[slot] = texgetbox(box)
+ -- textexts[slot] = texbox[box]
-- unsetbox(box)
end
function metapost.gettext(box,slot)
- texsetbox(box,copy_list(top.textexts[slot]))
+ texbox[box] = copy_list(textexts[slot])
if trace_textexts then
report_textexts("putting text %s in box %s",slot,box)
end
- -- top.textexts[slot] = nil -- no, pictures can be placed several times
+ -- textexts[slot] = nil -- no, pictures can be placed several times
end
-- rather generic pdf, so use this elsewhere too it no longer pays
@@ -502,10 +489,7 @@ local do_safeguard = ";"
local f_text_data = formatters["mfun_tt_w[%i] := %f ; mfun_tt_h[%i] := %f ; mfun_tt_d[%i] := %f ;"]
function metapost.textextsdata()
- local texorder = top.texorder
- local textexts = top.textexts
- local collected = { }
- local nofcollected = 0
+ local t, nt, n = { }, 0, 0
for n=1,#texorder do
local box = textexts[texorder[n]]
if box then
@@ -513,23 +497,25 @@ function metapost.textextsdata()
if trace_textexts then
report_textexts("passed data item %s: (%p,%p,%p)",n,wd,ht,dp)
end
- nofcollected = nofcollected + 1
- collected[nofcollected] = f_text_data(n,wd,n,ht,n,dp)
+ nt = nt + 1
+ t[nt] = f_text_data(n,wd,n,ht,n,dp)
else
break
end
end
- return collected
+-- inspect(t)
+ return t
end
-metapost.intermediate = metapost.intermediate or { }
-metapost.intermediate.actions = metapost.intermediate.actions or { }
+metapost.intermediate = metapost.intermediate or {}
+metapost.intermediate.actions = metapost.intermediate.actions or {}
+metapost.intermediate.needed = false
metapost.method = 1 -- 1:dumb 2:clever
-- maybe we can latelua the texts some day
-local processmetapost = metapost.process
+local nofruns = 0 -- askedfig: "all", "first", number
local function checkaskedfig(askedfig) -- return askedfig, wrappit
if not askedfig then
@@ -548,42 +534,18 @@ local function checkaskedfig(askedfig) -- return askedfig, wrappit
end
end
-local function extrapass()
- if trace_runs then
- report_metapost("second run of job %s, asked figure %a",top.nofruns,top.askedfig)
- end
- processmetapost(top.mpx, {
- top.wrappit and do_begin_fig or "",
- no_trial_run,
- concat(metapost.textextsdata()," ;\n"),
- top.initializations,
- do_safeguard,
- top.data,
- top.wrappit and do_end_fig or "",
- }, false, nil, false, true, top.askedfig)
- -- context.MPLIBresettexts() -- must happen afterwards
-end
-
-function metapost.graphic_base_pass(specification) -- name will change (see mlib-ctx.lua)
- local top = startjob(true)
- --
- local mpx = specification.mpx -- mandate
- local data = specification.data or ""
- local definitions = specification.definitions or ""
- -- local extensions = metapost.getextensions(specification.instance,specification.useextensions)
- local extensions = specification.extensions or ""
- local inclusions = specification.inclusions or ""
+function metapost.graphic_base_pass(specification)
+ local mpx = specification.mpx -- mandate
+ local data = specification.data or ""
+ local definitions = specification.definitions or ""
+-- local extensions = metapost.getextensions(specification.instance,specification.useextensions)
+ local extensions = specification.extensions or ""
+ local inclusions = specification.inclusions or ""
local initializations = specification.initializations or ""
- local askedfig = specification.figure -- no default else no wrapper
+ local askedfig = specification.figure -- no default else no wrapper
--
+ nofruns = nofruns + 1
local askedfig, wrappit = checkaskedfig(askedfig)
- --
- nofruns = nofruns + 1
- --
- top.askedfig = askedfig
- top.wrappit = wrappit
- top.nofruns = nofruns
- --
local done_1, done_2, done_3, forced_1, forced_2, forced_3
data, done_1, forced_1 = checktexts(data)
-- we had preamble = extensions + inclusions
@@ -597,12 +559,12 @@ function metapost.graphic_base_pass(specification) -- name will change (see mlib
else
inclusions, done_3, forced_3 = checktexts(inclusions)
end
- top.intermediate = false
- top.multipass = false -- no needed here
- top.mpx = mpx
- top.data = data
- top.initializations = initializations
- local method = metapost.method
+ metapost.intermediate.needed = false
+ metapost.multipass = false -- no needed here
+ current_format = mpx
+ current_graphic = data
+ current_initializations = initializations
+ local method = metapost.method
if trace_runs then
if method == 1 then
report_metapost("forcing two runs due to library configuration")
@@ -623,19 +585,19 @@ function metapost.graphic_base_pass(specification) -- name will change (see mlib
report_metapost("first run of job %s, asked figure %a",nofruns,askedfig)
end
-- first true means: trialrun, second true means: avoid extra run if no multipass
- local flushed = processmetapost(mpx, {
+ local flushed = metapost.process(mpx, {
definitions,
extensions,
inclusions,
wrappit and do_begin_fig or "",
do_first_run,
do_trial_run,
- initializations,
+ current_initializations,
do_safeguard,
- data,
+ current_graphic,
wrappit and do_end_fig or "",
}, true, nil, not (forced_1 or forced_2 or forced_3), false, askedfig)
- if top.intermediate then
+ if metapost.intermediate.needed then
for _, action in next, metapost.intermediate.actions do
action()
end
@@ -643,35 +605,44 @@ function metapost.graphic_base_pass(specification) -- name will change (see mlib
if not flushed or not metapost.optimize then
-- tricky, we can only ask once for objects and therefore
-- we really need a second run when not optimized
- -- context.MPLIBextrapass(askedfig)
- context(extrapass)
+ context.MPLIBextrapass(askedfig)
end
else
if trace_runs then
report_metapost("running job %s, asked figure %a",nofruns,askedfig)
end
- processmetapost(mpx, {
+ metapost.process(mpx, {
preamble,
wrappit and do_begin_fig or "",
do_first_run,
no_trial_run,
- initializations,
+ current_initializations,
do_safeguard,
- data,
+ current_graphic,
wrappit and do_end_fig or "",
}, false, nil, false, false, askedfig)
end
- context(stopjob)
end
-function metapost.process(...)
- startjob(false)
- processmetapost(...)
- stopjob()
+function metapost.graphic_extra_pass(askedfig)
+ if trace_runs then
+ report_metapost("second run of job %s, asked figure %a",nofruns,askedfig)
+ end
+ local askedfig, wrappit = checkaskedfig(askedfig)
+ metapost.process(current_format, {
+ wrappit and do_begin_fig or "",
+ no_trial_run,
+ concat(metapost.textextsdata()," ;\n"),
+ current_initializations,
+ do_safeguard,
+ current_graphic,
+ wrappit and do_end_fig or "",
+ }, false, nil, false, true, askedfig)
+ context.MPLIBresettexts() -- must happen afterwards
end
local start = [[\starttext]]
-local preamble = [[\def\MPLIBgraphictext#1{\startTEXpage[scale=10000]#1\stopTEXpage}]]
+local preamble = [[\long\def\MPLIBgraphictext#1{\startTEXpage[scale=10000]#1\stopTEXpage}]]
local stop = [[\stoptext]]
function makempy.processgraphics(graphics)
@@ -687,20 +658,15 @@ function makempy.processgraphics(graphics)
os.execute(command)
if io.exists(pdffile) then
command = format("pstoedit -ssp -dt -f mpost %s %s", pdffile, mpyfile)
- logs.newline()
- report_metapost("running: %s",command)
- logs.newline()
os.execute(command)
local result, r = { }, 0
if io.exists(mpyfile) then
local data = io.loaddata(mpyfile)
- if data and #data > 0 then
- for figure in gmatch(data,"beginfig(.-)endfig") do
- r = r + 1
- result[r] = formatters["begingraphictextfig%sendgraphictextfig ;\n"](figure)
- end
- io.savedata(mpyfile,concat(result,""))
+ for figure in gmatch(data,"beginfig(.-)endfig") do
+ r = r + 1
+ result[r] = formatters["begingraphictextfig%sendgraphictextfig ;\n"](figure)
end
+ io.savedata(mpyfile,concat(result,""))
end
end
stoptiming(makempy)
@@ -721,9 +687,9 @@ local resetteractions = sequencers.new { arguments = "t" }
local analyzeractions = sequencers.new { arguments = "object,prescript" }
local processoractions = sequencers.new { arguments = "object,prescript,before,after" }
-appendgroup(resetteractions, "system")
-appendgroup(analyzeractions, "system")
-appendgroup(processoractions,"system")
+appendgroup(resetteractions, "system")
+appendgroup(analyzeractions, "system")
+appendgroup(processoractions, "system")
-- later entries come first
@@ -762,56 +728,48 @@ end
-- end
function metapost.pluginactions(what,t,flushfigure) -- before/after object, depending on what
- if top.texmode then
- 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
+ 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
- return t
end
+ return t
end
function metapost.resetplugins(t) -- intialize plugins, before figure
- if top.texmode then
- -- plugins can have been added
- resetter = resetteractions.runner
- analyzer = analyzeractions.runner
- processor = processoractions.runner
- -- let's apply one runner
- resetter(t)
- end
+ -- plugins can have been added
+ resetter = resetteractions .runner
+ analyzer = analyzeractions .runner
+ processor = processoractions .runner
+ -- let's apply one runner
+ resetter(t)
end
function metapost.analyzeplugins(object) -- each object (first pass)
- if top.texmode then
- local prescript = object.prescript -- specifications
- if prescript and #prescript > 0 then
- return analyzer(object,splitprescript(prescript))
- end
+ local prescript = object.prescript -- specifications
+ if prescript and #prescript > 0 then
+ return analyzer(object,splitprescript(prescript))
end
end
function metapost.processplugins(object) -- each object (second pass)
- if top.texmode then
- local prescript = object.prescript -- specifications
- if prescript and #prescript > 0 then
- local before = { }
- local after = { }
- processor(object,splitprescript(prescript),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
+ local prescript = object.prescript -- specifications
+ if prescript and #prescript > 0 then
+ local before = { }
+ local after = { }
+ processor(object,splitprescript(prescript),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
@@ -841,37 +799,29 @@ local function cl_reset(t)
t[#t+1] = metapost.colorinitializer() -- only color
end
+local tx_hash = { }
+local tx_last = 0
+
local function tx_reset()
- if top then
- top.texhash = { }
- top.texlast = 0
- end
+ tx_hash = { }
+ tx_last = 0
end
local fmt = formatters["%s %s %s % t"]
-local pat = lpeg.tsplitat(":")
local function tx_analyze(object,prescript) -- todo: hash content and reuse them
local tx_stage = prescript.tx_stage
if tx_stage == "trial" then
- local tx_trial = top.textrial + 1
- top.textrial = tx_trial
+ textrial = textrial + 1
local tx_number = tonumber(prescript.tx_number)
local s = object.postscript or ""
local c = object.color -- only simple ones, no transparency
- if #c == 0 then
- local txc = prescript.tx_color
- if txc then
- c = lpegmatch(pat,txc)
- end
- end
local a = prescript.tr_alternative
local t = prescript.tr_transparency
- local h = fmt(tx_number,a or "-",t or "-",c or "-")
- local n = top.texhash[h] -- todo: hashed variant with s (nicer for similar labels)
+ local h = fmt(tx_number,a or "?",t or "?",c)
+ local n = tx_hash[h] -- todo: hashed variant with s (nicer for similar labels)
if not n then
- local tx_last = top.texlast + 1
- top.texlast = tx_last
+ tx_last = tx_last + 1
if not c then
-- no color
elseif #c == 1 then
@@ -894,35 +844,31 @@ local function tx_analyze(object,prescript) -- todo: hash content and reuse them
end
end
context.MPLIBsettext(tx_last,s)
- top.multipass = true
- metapost.multipass = true -- ugly
- top.texhash[h] = tx_last
- top.texslots[tx_trial] = tx_last
- top.texorder[tx_number] = tx_last
+ metapost.multipass = true
+ tx_hash[h] = tx_last
+ texslots[textrial] = tx_last
+ texorder[tx_number] = tx_last
if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, new %a, hash %a",tx_stage,tx_trial,tx_number,tx_last,h)
+ report_textexts("stage %a, usage %a, number %a, new %a, hash %a",tx_stage,textrial,tx_number,tx_last,h)
end
else
- top.texslots[tx_trial] = n
+ texslots[textrial] = n
if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, new %a, hash %a",tx_stage,tx_trial,tx_number,n,h)
+ report_textexts("stage %a, usage %a, number %a, new %a, hash %a",tx_stage,textrial,tx_number,n,h)
end
end
elseif tx_stage == "extra" then
- local tx_trial = top.textrial + 1
- top.textrial = tx_trial
+ textrial = textrial + 1
local tx_number = tonumber(prescript.tx_number)
- if not top.texorder[tx_number] then
+ if not texorder[tx_number] then
local s = object.postscript or ""
- local tx_last = top.texlast + 1
- top.texlast = tx_last
+ tx_last = tx_last + 1
context.MPLIBsettext(tx_last,s)
- top.multipass = true
- metapost.multipass = true -- ugly
- top.texslots[tx_trial] = tx_last
- top.texorder[tx_number] = tx_last
+ metapost.multipass = true
+ texslots[textrial] = tx_last
+ texorder[tx_number] = tx_last
if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, extra %a",tx_stage,tx_trial,tx_number,tx_last)
+ report_textexts("stage %a, usage %a, number %a, extra %a",tx_stage,textrial,tx_number,tx_last)
end
end
end
@@ -934,13 +880,13 @@ local function tx_process(object,prescript,before,after)
tx_number = tonumber(tx_number)
local tx_stage = prescript.tx_stage
if tx_stage == "final" then
- top.texfinal = top.texfinal + 1
- local n = top.texslots[top.texfinal]
+ texfinal = texfinal + 1
+ local n = texslots[texfinal]
if trace_textexts then
- report_textexts("stage %a, usage %a, number %a, use %a",tx_stage,top.texfinal,tx_number,n)
+ report_textexts("stage %a, usage %a, number %a, use %a",tx_stage,texfinal,tx_number,n)
end
local sx, rx, ry, sy, tx, ty = cm(object) -- needs to be frozen outside the function
- local box = top.textexts[n]
+ local box = textexts[n]
if box then
before[#before+1] = function()
-- flush always happens, we can have a special flush function injected before
@@ -982,9 +928,8 @@ local function gt_analyze(object,prescript)
local gt_stage = prescript.gt_stage
if gt_stage == "trial" then
graphics[#graphics+1] = formatters["\\MPLIBgraphictext{%s}"](object.postscript or "")
- top.intermediate = true
- top.multipass = true
- metapost.multipass = true -- ugly
+ metapost.intermediate.needed = true
+ metapost.multipass = true
end
end
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index e16827585..f21d84e0d 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -33,41 +33,18 @@
\newbox \MPtextbox
\newtoks\everyMPLIBsettext % not used
+\newconditional\MPLIBtextgetdone
+
% \def\MPLIBsettext#1% #2%
% {\dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
-%
-% \def\MPLIBresettexts
-% {\ctxlua{metapost.resettextexts()}}
-%
-% \newconditional\MPLIBtextgetdone
-%
-% \def\MPLIBsettext#1% #2%
-% {\ifconditional\MPLIBtextgetdone
-% \else
-% \cldcontext{metapost.tex.get()}% MPenvironments are depricated
-% \settrue\MPLIBtextgetdone % no \global needed
-% \fi
-% \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
-%
-% \def\MPLIBresettexts
-% {\ctxlua{metapost.resettextexts()}%
-% \setfalse\MPLIBtextgetdone}
-
-\def\doMPLIBflushenvironment
- {%\writestatus\m!metapost{flushing environment}%
- \cldcontext{metapost.tex.get()}%
- \let\MPLIBflushenvironment\relax}% MPenvironments are depricated}
-
-\let\MPLIBflushenvironment\doMPLIBflushenvironment
\def\MPLIBsettext#1% #2%
- {\MPLIBflushenvironment
- \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox\bgroup
- \let\MPLIBflushenvironment\doMPLIBflushenvironment
- \let\next} % gobble open brace
-
-\def\MPLIBresettexts
- {\ctxlua{metapost.resettextexts()}}
+ {\ifconditional\MPLIBtextgetdone
+ \else
+ \cldcontext{metapost.tex.get()}% MPenvironments are depricated
+ \settrue\MPLIBtextgetdone % no \global needed
+ \fi
+ \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
{\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
@@ -78,7 +55,7 @@
\ctxlua{metapost.edefsxsy(\number\wd\scratchbox,\number\ht\scratchbox,0)}%
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=\sx,\c!sy=\sy]{\box\scratchbox}\hss}}}
-% horrible (we could inline scale and matrix code):
+% horrible:
\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
{\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
@@ -87,16 +64,16 @@
\vbox to \zeropoint\bgroup
\vss
\hbox 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}%
+% \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
+ % 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 % needed ? already in the scale macro
+ \hss
\egroup
\egroup
\egroup
@@ -135,8 +112,15 @@
\def\MPLIBpositionwhd#1#2#3#4#5% bp !
{\dosavepositionwhd{#1}\zerocount{#2\onebasepoint}{#3\onebasepoint}{#4\onebasepoint}{#5\onebasepoint}\zeropoint}
-% \def\MPLIBextrapass#1%
-% {\ctxlua{metapost.graphic_extra_pass("#1")}}
+\def\MPLIBextrapass#1%
+ {\ctxlua{metapost.graphic_extra_pass("#1")}}
+
+% \def\MPLIBresettexts
+% {\ctxlua{metapost.resettextexts()}}
+
+\def\MPLIBresettexts
+ {\ctxlua{metapost.resettextexts()}%$
+ \setfalse\MPLIBtextgetdone}
%D Experiment
diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua
index e2585998e..1fc36dd80 100644
--- a/tex/context/base/mlib-run.lua
+++ b/tex/context/base/mlib-run.lua
@@ -589,37 +589,3 @@ function metapost.directrun(formatname,filename,outputformat,astable,mpdata)
end
end
end
-
--- goodie
-
-function metapost.quickanddirty(mpxformat,data)
- if not data then
- mpxformat = "metafun"
- data = mpxformat
- end
- local code, bbox
- local flusher = {
- startfigure = function(n,llx,lly,urx,ury)
- code = { }
- bbox = { llx, lly, urx, ury }
- end,
- flushfigure = function(t)
- for i=1,#t do
- code[#code+1] = t[i]
- end
- end,
- stopfigure = function()
- end
- }
- local data = format("; beginfig(1) ;\n %s\n ; endfig ;",data)
- metapost.process(mpxformat, { data }, false, flusher, false, false, "all")
- if code then
- return {
- bbox = bbox or { 0, 0, 0, 0 },
- code = code,
- data = data,
- }
- else
- report_metapost("invalid quick and dirty run")
- end
-end
diff --git a/tex/context/base/mtx-context-xml.tex b/tex/context/base/mtx-context-xml.tex
deleted file mode 100644
index 63b1d6e9e..000000000
--- a/tex/context/base/mtx-context-xml.tex
+++ /dev/null
@@ -1,75 +0,0 @@
-%D \module
-%D [ file=mtx-context-xml,
-%D version=2013.05.30,
-%D title=\CONTEXT\ Extra Trickry,
-%D subtitle=Analyzing XML 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.
-
-% This module replaces mkii analyzers.
-
-% begin help
-%
-% usage: context --extra=xml [options] list-of-files
-%
-% --analyze : show elements and characters
-% --topspace=dimension : distance above first line
-% --backspace=dimension : distance before left margin
-% --bodyfont=list : additional bodyfont settings
-% --paperformat=spec : paper*print or paperxprint
-%
-% end help
-
-\input mtx-context-common.tex
-
-\setupbodyfont
- [dejavu,11pt,tt,\getdocumentargument{bodyfont}]
-
-\setuptyping
- [lines=yes]
-
-\setuplayout
- [header=0cm,
- footer=1.5cm,
- topspace=\getdocumentargumentdefault{topspace}{1.5cm},
- backspace=\getdocumentargumentdefault{backspace}{1.5cm},
- width=middle,
- height=middle]
-
-\setuppapersize
- [\getdocumentargument{paperformat_paper}]
- [\getdocumentargument{paperformat_print}]
-
-\usemodule[xml-analyzers]
-
-\starttext
-
-\startluacode
- local pattern = document.arguments.pattern
- local files = document.files
-
- if pattern then
- files = dir.glob(pattern)
- context.setupfootertexts( { pattern }, { "pagenumber" })
- else
- context.setupfootertexts( { table.concat(files," ") }, { "pagenumber" })
- end
-
- if #files > 0 then
- if document.arguments.analyze then
- moduledata.xml.analyzers.structure (files)
- moduledata.xml.analyzers.characters(files)
- else
- context("no action given")
- end
- else
- context("no files given")
- end
-\stopluacode
-
-\stoptext
diff --git a/tex/context/base/mult-aux.lua b/tex/context/base/mult-aux.lua
index bdc626d4c..3c4cbcc0f 100644
--- a/tex/context/base/mult-aux.lua
+++ b/tex/context/base/mult-aux.lua
@@ -12,8 +12,6 @@ interfaces.namespaces = interfaces.namespaces or { }
local namespaces = interfaces.namespaces
local variables = interfaces.variables
-local context = context
-
local trace_namespaces = false trackers.register("interfaces.namespaces", function(v) trace_namespaces = v end)
local report_namespaces = logs.reporter("interface","namespaces")
diff --git a/tex/context/base/mult-de.mkii b/tex/context/base/mult-de.mkii
index 5f2714ce6..893a9d358 100644
--- a/tex/context/base/mult-de.mkii
+++ b/tex/context/base/mult-de.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{marginalkante}
\setinterfacevariable{margintitle}{marginaltitel}
\setinterfacevariable{marking}{beschriftung}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{mathalignment}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{mathematik}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{sectionblockenvironment}
\setinterfacevariable{sectionnumber}{abschnittsnummer}
\setinterfacevariable{see}{sieh}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{september}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{kleinerabstand}
\setinterfacevariable{setups}{impostazioni}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{kurz}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{einzelseitig}
\setinterfacevariable{slanted}{geneigt}
\setinterfacevariable{slantedbold}{geneigtfett}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blockauf}
\setinterfaceconstant{bodyfont}{fliesstext}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{unten}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{berechnen}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{cbefehl}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{klick}
\setinterfaceconstant{clickin}{klickin}
\setinterfaceconstant{clickout}{klickaus}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{component}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{compress}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{fortsetzen}
\setinterfaceconstant{contrastcolor}{kontrastfarbe}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{faktor}
\setinterfaceconstant{fallback}{fallback}
\setinterfaceconstant{family}{familie}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{feldhintergrundfarbe}
\setinterfaceconstant{fieldframecolor}{feldrahmenfarbe}
\setinterfaceconstant{fieldlayer}{fieldlayer}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{von}
\setinterfaceconstant{get}{hole}
\setinterfaceconstant{global}{global}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{gritter}
\setinterfaceconstant{hang}{haengend}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interaktion}
\setinterfaceconstant{interlinespace}{zeilenabstande}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemalign}
\setinterfaceconstant{items}{posten}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{marginalkante}
\setinterfaceconstant{marginedgetext}{marginalkantetext}
\setinterfaceconstant{margintext}{marginaltext}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{beschriftung}
\setinterfaceconstant{marstyle}{beschrstil}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{mindepth}
\setinterfaceconstant{minheight}{minhoehe}
\setinterfaceconstant{minwidth}{minbreite}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{name}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{oeffenaktion}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{openpageaction}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{option}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{orientation}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regionin}
\setinterfaceconstant{regionout}{regionaus}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{wiederholen}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{resetnumber}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{seperator}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{setups}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{nebenvorspatium}
\setinterfaceconstant{sign}{zeichen}
\setinterfaceconstant{size}{groesse}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{klein}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sorttype}
diff --git a/tex/context/base/mult-def.lua b/tex/context/base/mult-def.lua
index afd466531..fdb8803bf 100644
--- a/tex/context/base/mult-def.lua
+++ b/tex/context/base/mult-def.lua
@@ -6454,34 +6454,6 @@ return {
},
},
["constants"]={
- -- select/simplefonts
- ["regularfont"] ={ ["en"]="regularfont" },
- ["boldfont"] ={ ["en"]="boldfont" },
- ["italicfont"] ={ ["en"]="italicfont" },
- ["slantedfont"] ={ ["en"]="slantedfont" },
- ["bolditalicfont"] ={ ["en"]="bolditalicfont" },
- ["boldslantedfont"] ={ ["en"]="boldslantedfont" },
- ["smallcapsfont"] ={ ["en"]="smallcapsfont" },
- ["features"] ={ ["en"]="features" },
- ["regularfeatures"] ={ ["en"]="regularfeatures" },
- ["boldfeatures"] ={ ["en"]="boldfeatures" },
- ["italicfeatures"] ={ ["en"]="italicfeatures" },
- ["slantedfeatures"] ={ ["en"]="slantedfeatures" },
- ["bolditalicfeatures"] ={ ["en"]="bolditalicfeatures" },
- ["boldslantedfeatures"]={ ["en"]="boldslantedfeatures" },
- ["smallcapsfeatures"] ={ ["en"]="smallcapsfeatures" },
- ["opticalsize"] ={ ["en"]="opticalsize" },
- ["goodies"] ={ ["en"]="goodies" },
- ["check"] ={ ["en"]="check" },
- --
- ["separatorcolor"]={
- ["en"]="separatorcolor",
- ["nl"]="scheiderkleur",
- },
- ["separatorstyle"]={
- ["en"]="separatorstyle",
- ["nl"]="scheiderletter",
- },
["less"]={
["en"]="less",
["nl"]="minder",
@@ -7010,10 +6982,6 @@ return {
["pe"]="قبلازسر",
["ro"]="inaintetitlu",
},
- ["concerns"]={
- ["en"]="concerns",
- ["nl"]="betreft",
- },
["bet"]={
["cs"]="bet",
["de"]="bet",
@@ -8393,10 +8361,6 @@ return {
["pe"]="آیتمها",
["ro"]="elemente",
},
- ["mark"]={
- ["en"]="mark",
- ["nl"]="kernmerk",
- },
["ken"]={
["cs"]="ken",
["de"]="ken",
@@ -8960,32 +8924,6 @@ return {
["pe"]="کمترینعرض",
["ro"]="latimeminima",
},
- ["moffset"]={
- ["cs"]="moffset",
- ["de"]="moffset",
- ["en"]="moffset",
- ["fr"]="moffset",
- ["it"]="moffset",
- ["nl"]="moffset",
- ["pe"]="moffset",
- ["ro"]="moffset",
- },
- ["mpwidth"]={
- ["en"]="mpwidth",
- ["nl"]="mpbreedte",
- },
- ["mpheight"]={
- ["en"]="mpheight",
- ["nl"]="mphoogte",
- },
- ["mpdepth"]={
- ["en"]="mpdepth",
- ["nl"]="mpdiepte",
- },
- ["mpoffset"]={
- ["en"]="mpoffset",
- ["nl"]="mpoffset",
- },
["monthconversion"]={
["en"]="monthconversion",
["nl"]="maandconversie",
@@ -10425,15 +10363,9 @@ return {
["pe"]="بست",
["ro"]="strut",
},
- ["mathclass"]={
- ["en"]="mathclass",
- },
["mathstyle"]={
["en"]="mathstyle",
},
- ["mathlimits"]={
- ["en"]="mathlimits",
- },
["style"]={
["cs"]="pismeno",
["de"]="stil",
@@ -11393,15 +11325,6 @@ return {
},
},
["variables"]={
- ["math"]={
- ["en"]="math",
- },
- ["selectfont"]={
- ["en"]="selectfont",
- },
- ["simplefonts"]={
- ["en"]="simplefonts",
- },
["more"]={
["en"]="more",
["nl"]="meer",
diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv
index 0c52d5a92..cb165b055 100644
--- a/tex/context/base/mult-def.mkiv
+++ b/tex/context/base/mult-def.mkiv
@@ -34,8 +34,6 @@
% start todo:
-\def\c!fences {fences}
-
\def\c!language {language}
\def\c!compressseparator{compressseparator}
\def\c!renderingsetup {renderingsetup}
@@ -74,7 +72,6 @@
\def\v!words {words}
\def\v!combination {combination}
\def\v!norepeat {norepeat}
-\def\v!mixed {mixed}
\def\s!lcgreek {lcgreek}
\def\s!ucgreek {ucgreek}
@@ -91,15 +88,11 @@
\def\s!current {current}
-\def\s!rel {rel}
-\def\s!ord {ord}
-
\def\c!HL {HL}
\def\c!VL {VL}
\def\c!NL {NL}
\ifdefined\v!kerncharacters\else \def\v!kerncharacters{kerncharacters} \fi % no time now for translations should be a e! actually
-\ifdefined\v!letterspacing \else \def\v!letterspacing {letterspacing} \fi % no time now for translations should be a e! actually
\ifdefined\v!stretched \else \def\v!stretched {stretched} \fi
\ifdefined\v!vulgarfraction\else \def\v!vulgarfraction{vulgarfraction} \fi
\ifdefined\v!block \else \def\v!block {block} \fi
diff --git a/tex/context/base/mult-en.mkii b/tex/context/base/mult-en.mkii
index 97732dab7..c3ab2fc16 100644
--- a/tex/context/base/mult-en.mkii
+++ b/tex/context/base/mult-en.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{marginedge}
\setinterfacevariable{margintitle}{margintitle}
\setinterfacevariable{marking}{marking}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{mathalignment}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{mathematics}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{sectionblockenvironment}
\setinterfacevariable{sectionnumber}{sectionnumber}
\setinterfacevariable{see}{see}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{september}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{serried}
\setinterfacevariable{setups}{setups}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{short}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{singlesided}
\setinterfacevariable{slanted}{slanted}
\setinterfacevariable{slantedbold}{slantedbold}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{bodyfont}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{bottom}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{calculate}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{ccommand}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{click}
\setinterfaceconstant{clickin}{clickin}
\setinterfaceconstant{clickout}{clickout}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{component}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{compress}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{continue}
\setinterfaceconstant{contrastcolor}{contrastcolor}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{factor}
\setinterfaceconstant{fallback}{fallback}
\setinterfaceconstant{family}{family}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{fieldbackgroundcolor}
\setinterfaceconstant{fieldframecolor}{fieldframecolor}
\setinterfaceconstant{fieldlayer}{fieldlayer}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{from}
\setinterfaceconstant{get}{get}
\setinterfaceconstant{global}{global}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{grid}
\setinterfaceconstant{hang}{hang}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interaction}
\setinterfaceconstant{interlinespace}{interlinespace}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemalign}
\setinterfaceconstant{items}{items}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{marginedge}
\setinterfaceconstant{marginedgetext}{marginedgetext}
\setinterfaceconstant{margintext}{margintext}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{marking}
\setinterfaceconstant{marstyle}{marstyle}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{mindepth}
\setinterfaceconstant{minheight}{minheight}
\setinterfaceconstant{minwidth}{minwidth}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{name}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{openaction}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{openpageaction}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{option}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{orientation}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regionin}
\setinterfaceconstant{regionout}{regionout}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{repeat}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{resetnumber}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{separator}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{setups}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{sidespacebefore}
\setinterfaceconstant{sign}{sign}
\setinterfaceconstant{size}{size}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{small}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sorttype}
diff --git a/tex/context/base/mult-fr.mkii b/tex/context/base/mult-fr.mkii
index 520f8e1a6..1ba4f3c8c 100644
--- a/tex/context/base/mult-fr.mkii
+++ b/tex/context/base/mult-fr.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{bordmarge}
\setinterfacevariable{margintitle}{titremarge}
\setinterfacevariable{marking}{marquage}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{mathalignment}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{mathematique}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{environementblocsection}
\setinterfacevariable{sectionnumber}{numerosection}
\setinterfacevariable{see}{voit}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{septembre}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{serried}
\setinterfacevariable{setups}{reglages}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{short}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{recto}
\setinterfacevariable{slanted}{incline}
\setinterfacevariable{slantedbold}{grasincline}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{policecorps}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{marquepage}
\setinterfaceconstant{bottom}{inf}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{calculer}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{ccommande}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{clic}
\setinterfaceconstant{clickin}{clicinterieur}
\setinterfaceconstant{clickout}{clicexterieur}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{composant}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{compress}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{continue}
\setinterfaceconstant{contrastcolor}{coleurcontraste}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{facteur}
\setinterfaceconstant{fallback}{fallback}
\setinterfaceconstant{family}{famille}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{couleurarrierreplanchamp}
\setinterfaceconstant{fieldframecolor}{couleurcadrechamp}
\setinterfaceconstant{fieldlayer}{calquechamp}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{de}
\setinterfaceconstant{get}{obtient}
\setinterfaceconstant{global}{global}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{grille}
\setinterfaceconstant{hang}{suspend}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interaction}
\setinterfaceconstant{interlinespace}{espaceinterligne}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemalign}
\setinterfaceconstant{items}{elements}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{bordmarge}
\setinterfaceconstant{marginedgetext}{textebordmarge}
\setinterfaceconstant{margintext}{textemarge}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{marquage}
\setinterfaceconstant{marstyle}{stylemarquage}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{profondeurmin}
\setinterfaceconstant{minheight}{hauteurmin}
\setinterfaceconstant{minwidth}{largeurmin}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{nom}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{actionouverture}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{actionouverturepage}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{option}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{orientation}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{entreregion}
\setinterfaceconstant{regionout}{regionexterieure}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{repete}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{raznumero}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{separateur}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{reglages}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{espacelateralavant}
\setinterfaceconstant{sign}{signe}
\setinterfaceconstant{size}{dimension}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{petit}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sorttype}
diff --git a/tex/context/base/mult-fun.lua b/tex/context/base/mult-fun.lua
index 3867489bf..a661c53bb 100644
--- a/tex/context/base/mult-fun.lua
+++ b/tex/context/base/mult-fun.lua
@@ -96,10 +96,6 @@ return {
"drawpath", "drawpoint", "drawpoints", "drawcontrolpoints", "drawcontrollines", "drawpointlabels",
"drawlineoptions", "drawpointoptions", "drawcontroloptions", "drawlabeloptions", "draworiginoptions", "drawboundoptions", "drawpathoptions", "resetdrawoptions",
--
- "undashed",
- --
"decorated", "redecorated", "undecorated",
- --
- "passvariable",
},
}
diff --git a/tex/context/base/mult-ini.lua b/tex/context/base/mult-ini.lua
index e3ff904a6..3b18738de 100644
--- a/tex/context/base/mult-ini.lua
+++ b/tex/context/base/mult-ini.lua
@@ -10,9 +10,6 @@ local format, gmatch, match = string.format, string.gmatch, string.match
local lpegmatch = lpeg.match
local serialize = table.serialize
-local context = context
-local commands = commands
-
local allocate = utilities.storage.allocate
local mark = utilities.storage.mark
local prtcatcodes = catcodes.numbers.prtcatcodes
diff --git a/tex/context/base/mult-it.mkii b/tex/context/base/mult-it.mkii
index 2b31e8e10..0d1ea911d 100644
--- a/tex/context/base/mult-it.mkii
+++ b/tex/context/base/mult-it.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{bordomargine}
\setinterfacevariable{margintitle}{titoloinmargine}
\setinterfacevariable{marking}{marcatura}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{mathalignment}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{matematica}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{ambientebloccosezione}
\setinterfacevariable{sectionnumber}{numerosezione}
\setinterfacevariable{see}{vedi}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{settembre}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{vicino}
\setinterfacevariable{setups}{nastaveni}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{short}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{facciasingola}
\setinterfacevariable{slanted}{inclinato}
\setinterfacevariable{slantedbold}{inclinatograssetto}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{fonttesto}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{segnalibro}
\setinterfaceconstant{bottom}{fondo}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{calcola}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{ccomando}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{click}
\setinterfaceconstant{clickin}{clickdentro}
\setinterfaceconstant{clickout}{clickfuori}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{component}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{compress}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{continua}
\setinterfaceconstant{contrastcolor}{colorecontrasto}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{fattore}
\setinterfaceconstant{fallback}{fallback}
\setinterfaceconstant{family}{famiglia}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{coloresfondocampo}
\setinterfaceconstant{fieldframecolor}{colorecornicecampo}
\setinterfaceconstant{fieldlayer}{fieldlayer}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{da}
\setinterfaceconstant{get}{prendi}
\setinterfaceconstant{global}{globale}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{griglia}
\setinterfaceconstant{hang}{sospendi}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interazione}
\setinterfaceconstant{interlinespace}{interlinea}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemalign}
\setinterfaceconstant{items}{elementi}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{bordomargine}
\setinterfaceconstant{marginedgetext}{testobordomargine}
\setinterfaceconstant{margintext}{testomargine}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{marcatura}
\setinterfaceconstant{marstyle}{stilemarcatura}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{mindeoth}
\setinterfaceconstant{minheight}{altezzamin}
\setinterfaceconstant{minwidth}{ampiezzamin}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{nome}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{azioneapri}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{azioneapripagina}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{opzione}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{orientation}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{entraregione}
\setinterfaceconstant{regionout}{esciregione}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{ripeti}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{resetnumber}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{separatore}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{setups}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{spaziolateraleprima}
\setinterfaceconstant{sign}{segno}
\setinterfaceconstant{size}{dimensione}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{piccolo}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sorttype}
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index f82be039c..47e31978b 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -96,7 +96,7 @@ return {
"startproduct", "stopproduct", "product",
"startproject", "stopproject", "project",
"starttext", "stoptext", "startnotext", "stopnotext","startdocument", "stopdocument", "documentvariable", "setupdocument",
- "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule","setupmodule","currentmoduleparameter","moduleparameter",
+ "startmodule", "stopmodule", "usemodule", "usetexmodule", "useluamodule",
--
"startTEXpage", "stopTEXpage",
-- "startMPpage", "stopMPpage", -- already catched by nested lexer
@@ -116,14 +116,6 @@ return {
"continueifinputfile",
--
"luastringsep", "!!bs", "!!es",
- --
- "lefttorightmark", "righttoleftmark",
- --
- "breakablethinspace", "nobreakspace", "narrownobreakspace", "zerowidthnobreakspace",
- "ideographicspace", "ideographichalffillspace",
- "twoperemspace", "threeperemspace", "fourperemspace", "fiveperemspace", "sixperemspace",
- "figurespace", "punctuationspace", "hairspace",
- "zerowidthspace", "zerowidthnonjoiner", "zerowidthjoiner", "zwnj", "zwj",
},
["helpers"] = {
--
@@ -180,7 +172,7 @@ return {
--
"ruledhss", "ruledhfil", "ruledhfill", "ruledhfilneg", "ruledhfillneg", "normalhfillneg",
"ruledvss", "ruledvfil", "ruledvfill", "ruledvfilneg", "ruledvfillneg", "normalvfillneg",
- "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter", "ruledmbox",
+ "ruledhbox", "ruledvbox", "ruledvtop", "ruledvcenter",
"ruledhskip", "ruledvskip", "ruledkern", "ruledmskip", "ruledmkern",
"ruledhglue", "ruledvglue", "normalhglue", "normalvglue",
"ruledpenalty",
@@ -194,8 +186,6 @@ return {
"scratchtoks", "globalscratchtoks",
"scratchbox", "globalscratchbox",
--
- "normalbaselineskip", "normallineskip", "normallineskiplimit",
- --
"availablehsize", "localhsize", "setlocalhsize",
--
"nextbox", "dowithnextbox", "dowithnextboxcs", "dowithnextboxcontent", "dowithnextboxcontentcs",
@@ -298,8 +288,6 @@ return {
--
"twodigits","threedigits",
--
- "leftorright",
- --
"strut", "setstrut", "strutbox", "strutht", "strutdp", "strutwd", "struthtdp", "begstrut", "endstrut", "lineheight",
--
"ordordspacing", "ordopspacing", "ordbinspacing", "ordrelspacing",
@@ -354,16 +342,6 @@ return {
--
"carryoverpar",
--
- "assumelongusagecs",
- --
"Umathbotaccent",
- --
- "righttolefthbox", "lefttorighthbox", "righttoleftvbox", "lefttorightvbox", "righttoleftvtop", "lefttorightvtop",
- "rtlhbox", "ltrhbox", "rtlvbox", "ltrvbox", "rtlvtop", "ltrvtop",
- "autodirhbox", "autodirvbox", "autodirvtop",
- "lefttoright", "righttoleft","synchronizelayoutdirection","synchronizedisplaydirection","synchronizeinlinedirection",
- --
- "lesshyphens", "morehyphens", "nohyphens", "dohyphens",
- --
}
}
diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua
index 5a320487a..59411cd97 100644
--- a/tex/context/base/mult-mps.lua
+++ b/tex/context/base/mult-mps.lua
@@ -51,17 +51,15 @@ return {
"top", "bot", "lft", "rt", "ulft", "urt", "llft", "lrt",
--
"redpart", "greenpart", "bluepart", "cyanpart", "magentapart", "yellowpart", "blackpart", "greypart",
- "prescriptpart", "postscriptpart",
"rgbcolor", "cmykcolor", "greycolor", "graycolor",
"colormodel", "graypart",
"dashpart", "penpart",
-- "colorpart",
- "stroked", "filled", "textual", "clipped", "bounded", "pathpart",
+ "stroked", "filled", "textual", "clipped", "bounded",
"expandafter",
},
commands = {
"beginfig", "endfig",
- "beginglyph", "endglyph", "charscale",
"rotatedaround", "reflectedabout",
"arrowhead",
"currentpen", "currentpicture", "cuttings",
@@ -105,8 +103,6 @@ return {
"graypart", "graycolor",
--
"mm", "pt", "dd", "bp", "cm", "pc", "cc", "in",
- --
- "triplet", "quadruplet",
},
internals = { -- we need to remove duplicates above
--
diff --git a/tex/context/base/mult-nl.mkii b/tex/context/base/mult-nl.mkii
index 9f91515cb..5f1bada7a 100644
--- a/tex/context/base/mult-nl.mkii
+++ b/tex/context/base/mult-nl.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{kantlijn}
\setinterfacevariable{margintitle}{margetitel}
\setinterfacevariable{marking}{markering}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{wiskundeuitlijnen}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{wiskunde}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{sectieblokomgeving}
\setinterfacevariable{sectionnumber}{sectienummer}
\setinterfacevariable{see}{zie}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{september}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{aanelkaar}
\setinterfacevariable{setups}{instellingen}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{kort}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{enkelzijdig}
\setinterfacevariable{slanted}{schuin}
\setinterfacevariable{slantedbold}{schuinvet}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blokwijze}
\setinterfaceconstant{bodyfont}{korps}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{bookmark}
\setinterfaceconstant{bottom}{onder}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{bereken}
\setinterfaceconstant{category}{categorie}
\setinterfaceconstant{ccommand}{ccommando}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{klik}
\setinterfaceconstant{clickin}{klikin}
\setinterfaceconstant{clickout}{klikuit}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{component}
\setinterfaceconstant{compoundhyphen}{koppelteken}
\setinterfaceconstant{compress}{comprimeren}
-\setinterfaceconstant{concerns}{betreft}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{doorgaan}
\setinterfaceconstant{contrastcolor}{contrastkleur}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{factor}
\setinterfaceconstant{fallback}{terugval}
\setinterfaceconstant{family}{soort}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{veldachtergrondkleur}
\setinterfaceconstant{fieldframecolor}{veldkaderkleur}
\setinterfaceconstant{fieldlayer}{veldlaag}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{van}
\setinterfaceconstant{get}{haal}
\setinterfaceconstant{global}{globaal}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{grid}
\setinterfaceconstant{hang}{hang}
\setinterfaceconstant{hcompact}{hcomprimeer}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interactie}
\setinterfaceconstant{interlinespace}{interlinie}
\setinterfaceconstant{internalgrid}{interngrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemuitlijnen}
\setinterfaceconstant{items}{items}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{kantlijn}
\setinterfaceconstant{marginedgetext}{kantlijntekst}
\setinterfaceconstant{margintext}{margetekst}
-\setinterfaceconstant{mark}{kernmerk}
\setinterfaceconstant{marking}{markering}
\setinterfaceconstant{marstyle}{marletter}
\setinterfaceconstant{mask}{masker}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{mindiepte}
\setinterfaceconstant{minheight}{minhoogte}
\setinterfaceconstant{minwidth}{minbreedte}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{maandconversie}
\setinterfaceconstant{more}{meer}
-\setinterfaceconstant{mpdepth}{mpdiepte}
-\setinterfaceconstant{mpheight}{mphoogte}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpbreedte}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{naam}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{openactie}
\setinterfaceconstant{openpage}{openpagina}
\setinterfaceconstant{openpageaction}{openpaginaactie}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{optie}
\setinterfaceconstant{order}{volgorde}
\setinterfaceconstant{orientation}{orientatie}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{gebied}
\setinterfaceconstant{regionin}{gebiedin}
\setinterfaceconstant{regionout}{gebieduit}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{herhaal}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{resetnummer}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{scheider}
-\setinterfaceconstant{separatorcolor}{scheiderkleur}
-\setinterfaceconstant{separatorstyle}{scheiderletter}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{setups}
\setinterfaceconstant{shrink}{krimp}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{zijvoorwit}
\setinterfaceconstant{sign}{teken}
\setinterfaceconstant{size}{formaat}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{klein}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{oplossing}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sortering}
diff --git a/tex/context/base/mult-pe.mkii b/tex/context/base/mult-pe.mkii
index 240130cdf..f55a7ab59 100644
--- a/tex/context/base/mult-pe.mkii
+++ b/tex/context/base/mult-pe.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{لبهحاشیه}
\setinterfacevariable{margintitle}{عنوانحاشیه}
\setinterfacevariable{marking}{نشانهگذاری}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{تنظیمریاضی}
\setinterfacevariable{mathcases}{حالتهایریاضی}
\setinterfacevariable{mathematics}{ریاضی}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{محیطبلوکبخش}
\setinterfacevariable{sectionnumber}{شمارهبخش}
\setinterfacevariable{see}{ببینید}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{سپتامبر}
\setinterfacevariable{serif}{سریف}
\setinterfacevariable{serried}{تنگهم}
\setinterfacevariable{setups}{بارگذاریها}
\setinterfacevariable{sheet}{ورقه}
\setinterfacevariable{short}{short}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{یکرو}
\setinterfacevariable{slanted}{خوابیده}
\setinterfacevariable{slantedbold}{مشکیخوابیده}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{راهبلوک}
\setinterfaceconstant{bodyfont}{قلمبدنه}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{چوبخط}
\setinterfaceconstant{bottom}{پایین}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{محاسبه}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{فرمان}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{فشردن}
\setinterfaceconstant{clickin}{فشردنداخل}
\setinterfaceconstant{clickout}{فشردنخارج}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{مولفه}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{فشردن}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{ادامه}
\setinterfaceconstant{contrastcolor}{contrastcolor}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{عامل}
\setinterfaceconstant{fallback}{عقبریختن}
\setinterfaceconstant{family}{خانواده}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{رنگپسزمینهمیدان}
\setinterfaceconstant{fieldframecolor}{رنگقالبمیدان}
\setinterfaceconstant{fieldlayer}{لایهمیدان}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{از}
\setinterfaceconstant{get}{بگیر}
\setinterfaceconstant{global}{سراسری}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{توری}
\setinterfaceconstant{hang}{بیاویز}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{پانل}
\setinterfaceconstant{interlinespace}{فضایبینخط}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{تنظیمآیتم}
\setinterfaceconstant{items}{آیتمها}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{لبهحاشیه}
\setinterfaceconstant{marginedgetext}{متنلبهحاشیه}
\setinterfaceconstant{margintext}{متنحاشیه}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{نشانهگذاری}
\setinterfaceconstant{marstyle}{سبکحاش}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{بیشترین}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{کمترینعمق}
\setinterfaceconstant{minheight}{کمترینارتفاع}
\setinterfaceconstant{minwidth}{کمترینعرض}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{نام}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{عملباز}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{عملصفحهباز}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{گزینه}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{جهتدهی}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{ناحیهدرون}
\setinterfaceconstant{regionout}{ناحیهبیرون}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{تکرار}
\setinterfaceconstant{reset}{بازنشانی}
\setinterfaceconstant{resetnumber}{بازنشانیشماره}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{جداکننده}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{قراربده}
\setinterfaceconstant{setups}{بارگذاریها}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{فضایکناریقبل}
\setinterfaceconstant{sign}{علامت}
\setinterfaceconstant{size}{اندازه}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{کوچک}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{ترتیبتایپ}
diff --git a/tex/context/base/mult-ro.mkii b/tex/context/base/mult-ro.mkii
index 3b7206e44..34dd385a3 100644
--- a/tex/context/base/mult-ro.mkii
+++ b/tex/context/base/mult-ro.mkii
@@ -281,7 +281,6 @@
\setinterfacevariable{marginedge}{marginebordura}
\setinterfacevariable{margintitle}{titlumarginal}
\setinterfacevariable{marking}{marcaje}
-\setinterfacevariable{math}{math}
\setinterfacevariable{mathalignment}{mathalignment}
\setinterfacevariable{mathcases}{mathcases}
\setinterfacevariable{mathematics}{matematica}
@@ -415,14 +414,12 @@
\setinterfacevariable{sectionblockenvironment}{blocsectiuneambient}
\setinterfacevariable{sectionnumber}{numarsetiune}
\setinterfacevariable{see}{vezi}
-\setinterfacevariable{selectfont}{selectfont}
\setinterfacevariable{september}{septembrie}
\setinterfacevariable{serif}{serif}
\setinterfacevariable{serried}{serried}
\setinterfacevariable{setups}{setari}
\setinterfacevariable{sheet}{sheet}
\setinterfacevariable{short}{short}
-\setinterfacevariable{simplefonts}{simplefonts}
\setinterfacevariable{singlesided}{ofata}
\setinterfacevariable{slanted}{inclinat}
\setinterfacevariable{slantedbold}{inclinataldin}
@@ -596,12 +593,6 @@
\setinterfaceconstant{blockway}{blockway}
\setinterfaceconstant{bodyfont}{fonttext}
\setinterfaceconstant{boffset}{boffset}
-\setinterfaceconstant{boldfeatures}{boldfeatures}
-\setinterfaceconstant{boldfont}{boldfont}
-\setinterfaceconstant{bolditalicfeatures}{bolditalicfeatures}
-\setinterfaceconstant{bolditalicfont}{bolditalicfont}
-\setinterfaceconstant{boldslantedfeatures}{boldslantedfeatures}
-\setinterfaceconstant{boldslantedfont}{boldslantedfont}
\setinterfaceconstant{bookmark}{semncarte}
\setinterfaceconstant{bottom}{jos}
\setinterfaceconstant{bottomafter}{bottomafter}
@@ -617,7 +608,6 @@
\setinterfaceconstant{calculate}{calculeaza}
\setinterfaceconstant{category}{category}
\setinterfaceconstant{ccommand}{comandac}
-\setinterfaceconstant{check}{check}
\setinterfaceconstant{click}{click}
\setinterfaceconstant{clickin}{clickintru}
\setinterfaceconstant{clickout}{clickies}
@@ -640,7 +630,6 @@
\setinterfaceconstant{component}{component}
\setinterfaceconstant{compoundhyphen}{compoundhyphen}
\setinterfaceconstant{compress}{compress}
-\setinterfaceconstant{concerns}{concerns}
\setinterfaceconstant{connector}{connector}
\setinterfaceconstant{continue}{continua}
\setinterfaceconstant{contrastcolor}{culoarecontrast}
@@ -693,7 +682,6 @@
\setinterfaceconstant{factor}{factor}
\setinterfaceconstant{fallback}{fallback}
\setinterfaceconstant{family}{familie}
-\setinterfaceconstant{features}{features}
\setinterfaceconstant{fieldbackgroundcolor}{culoarefundalcamp}
\setinterfaceconstant{fieldframecolor}{culoareframecamp}
\setinterfaceconstant{fieldlayer}{fieldlayer}
@@ -723,7 +711,6 @@
\setinterfaceconstant{from}{dela}
\setinterfaceconstant{get}{adu}
\setinterfaceconstant{global}{global}
-\setinterfaceconstant{goodies}{goodies}
\setinterfaceconstant{grid}{grid}
\setinterfaceconstant{hang}{suspenda}
\setinterfaceconstant{hcompact}{hcompact}
@@ -760,8 +747,6 @@
\setinterfaceconstant{interaction}{interactiune}
\setinterfaceconstant{interlinespace}{spatiereinterliniara}
\setinterfaceconstant{internalgrid}{internalgrid}
-\setinterfaceconstant{italicfeatures}{italicfeatures}
-\setinterfaceconstant{italicfont}{italicfont}
\setinterfaceconstant{itemalign}{itemalign}
\setinterfaceconstant{items}{elemente}
\setinterfaceconstant{juniorsep}{juniorsep}
@@ -813,12 +798,9 @@
\setinterfaceconstant{marginedge}{coltbordura}
\setinterfaceconstant{marginedgetext}{textcoltbordura}
\setinterfaceconstant{margintext}{textmargine}
-\setinterfaceconstant{mark}{mark}
\setinterfaceconstant{marking}{marcaje}
\setinterfaceconstant{marstyle}{stilmarcaj}
\setinterfaceconstant{mask}{mask}
-\setinterfaceconstant{mathclass}{mathclass}
-\setinterfaceconstant{mathlimits}{mathlimits}
\setinterfaceconstant{mathstyle}{mathstyle}
\setinterfaceconstant{max}{max}
\setinterfaceconstant{maxdepth}{maxdepth}
@@ -836,13 +818,8 @@
\setinterfaceconstant{mindepth}{mindepth}
\setinterfaceconstant{minheight}{inaltimeminima}
\setinterfaceconstant{minwidth}{latimeminima}
-\setinterfaceconstant{moffset}{moffset}
\setinterfaceconstant{monthconversion}{monthconversion}
\setinterfaceconstant{more}{more}
-\setinterfaceconstant{mpdepth}{mpdepth}
-\setinterfaceconstant{mpheight}{mpheight}
-\setinterfaceconstant{mpoffset}{mpoffset}
-\setinterfaceconstant{mpwidth}{mpwidth}
\setinterfaceconstant{n}{n}
\setinterfaceconstant{name}{nume}
\setinterfaceconstant{namesep}{namesep}
@@ -882,7 +859,6 @@
\setinterfaceconstant{openaction}{actiunedeschidere}
\setinterfaceconstant{openpage}{openpage}
\setinterfaceconstant{openpageaction}{actiunedeschiderepagina}
-\setinterfaceconstant{opticalsize}{opticalsize}
\setinterfaceconstant{option}{optiune}
\setinterfaceconstant{order}{order}
\setinterfaceconstant{orientation}{orientation}
@@ -950,8 +926,6 @@
\setinterfaceconstant{region}{region}
\setinterfaceconstant{regionin}{regiuneintrare}
\setinterfaceconstant{regionout}{regiuneiesire}
-\setinterfaceconstant{regularfeatures}{regularfeatures}
-\setinterfaceconstant{regularfont}{regularfont}
\setinterfaceconstant{repeat}{repeta}
\setinterfaceconstant{reset}{reset}
\setinterfaceconstant{resetnumber}{resetnumber}
@@ -998,8 +972,6 @@
\setinterfaceconstant{sectionstarter}{sectionstarter}
\setinterfaceconstant{sectionstopper}{sectionstopper}
\setinterfaceconstant{separator}{separator}
-\setinterfaceconstant{separatorcolor}{separatorcolor}
-\setinterfaceconstant{separatorstyle}{separatorstyle}
\setinterfaceconstant{set}{set}
\setinterfaceconstant{setups}{setups}
\setinterfaceconstant{shrink}{shrink}
@@ -1010,11 +982,7 @@
\setinterfaceconstant{sidespacebefore}{spatiulateralinainte}
\setinterfaceconstant{sign}{semn}
\setinterfaceconstant{size}{dimensiune}
-\setinterfaceconstant{slantedfeatures}{slantedfeatures}
-\setinterfaceconstant{slantedfont}{slantedfont}
\setinterfaceconstant{small}{mic}
-\setinterfaceconstant{smallcapsfeatures}{smallcapsfeatures}
-\setinterfaceconstant{smallcapsfont}{smallcapsfont}
\setinterfaceconstant{solution}{solution}
\setinterfaceconstant{sort}{sort}
\setinterfaceconstant{sorttype}{sorttype}
diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv
index 6c6db58e1..f0db9fa67 100644
--- a/tex/context/base/mult-sys.mkiv
+++ b/tex/context/base/mult-sys.mkiv
@@ -163,9 +163,6 @@
\definesystemconstant {both}
-\definesystemconstant {internal}
-\definesystemconstant {external}
-
\definesystemconstant {attribute}
\definesystemconstant {none}
@@ -561,12 +558,11 @@
%D calls to other files), old macro's, to garantee compatibility and new macro's noy
%D yet present in the format.
-\definefileconstant {sysfilename} {cont-sys.mkiv}
-\definefileconstant {newfilename} {cont-new.mkiv}
-\definefileconstant {locfilename} {cont-loc.mkiv}
-\definefileconstant {expfilename} {cont-exp.mkiv}
-\definefileconstant {fntfilename} {cont-fnt.mkiv} % not yet used
-\definefileconstant {gdsfilename} {cont-fnt.lfg} % not yet used
+\definefileconstant {errfilename} {cont-err}
+\definefileconstant {sysfilename} {cont-sys}
+\definefileconstant {newfilename} {cont-new}
+\definefileconstant {locfilename} {cont-loc}
+\definefileconstant {expfilename} {cont-exp}
%D The setup files for the language, font, color and special subsystems have a common
%D prefix. This means that we have at most three characters for unique filenames.
diff --git a/tex/context/base/node-acc.lua b/tex/context/base/node-acc.lua
index 81ae496b2..4380ec3a4 100644
--- a/tex/context/base/node-acc.lua
+++ b/tex/context/base/node-acc.lua
@@ -35,7 +35,7 @@ local function injectspaces(head)
while n do
local id = n.id
if id == glue_code then -- todo: check for subtype related to spacing (13/14 but most seems to be 0)
- -- if n.spec.width > 0 then -- threshold
+--~ if n.spec.width > 0 then -- threshold
if p and p.id == glyph_code then
local g = copy_node(p)
local c = g.components
@@ -56,7 +56,7 @@ local function injectspaces(head)
s[a_characters] = 0
n[a_characters] = 0
end
- -- end
+--~ end
elseif id == hlist_code or id == vlist_code then
injectspaces(n.list,attribute)
-- elseif id == kern_code then -- the backend already collapses
@@ -83,58 +83,58 @@ nodes.handlers.accessibility = injectspaces
-- todo:
--- local a_hyphenated = attributes.private('hyphenated')
---
--- local hyphenated, codes = { }, { }
---
--- local function compact(n)
--- local t = { }
--- for n in traverse_id(glyph_code,n) do
--- t[#t+1] = utfchar(n.char) -- check for unicode
--- end
--- return concat(t,"")
--- end
---
--- local function injectspans(head)
--- for n in traverse_nodes(head) do
--- local id = n.id
--- if id == disc then
--- local r, p = n.replace, n.pre
--- if r and p then
--- local str = compact(r)
--- local hsh = hyphenated[str]
--- if not hsh then
--- hsh = #codes + 1
--- hyphenated[str] = hsh
--- codes[hsh] = str
--- end
--- n[a_hyphenated] = hsh
--- end
--- elseif id == hlist_code or id == vlist_code then
--- injectspans(n.list)
--- end
--- end
--- return head, true
--- end
---
--- nodes.injectspans = injectspans
---
--- tasks.appendaction("processors", "words", "nodes.injectspans")
---
--- local function injectspans(head)
--- for n in traverse_nodes(head) do
--- local id = n.id
--- if id == disc then
--- local a = n[a_hyphenated]
--- if a then
--- local str = codes[a]
--- local b = new_pdfliteral(format("/Span << /ActualText %s >> BDC", lpdf.tosixteen(str)))
--- local e = new_pdfliteral("EMC")
--- node.insert_before(head,n,b)
--- node.insert_after(head,n,e)
--- end
--- elseif id == hlist_code or id == vlist_code then
--- injectspans(n.list)
--- end
--- end
--- end
+--~ local a_hyphenated = attributes.private('hyphenated')
+--~
+--~ local hyphenated, codes = { }, { }
+--~
+--~ local function compact(n)
+--~ local t = { }
+--~ for n in traverse_id(glyph_code,n) do
+--~ t[#t+1] = utfchar(n.char) -- check for unicode
+--~ end
+--~ return concat(t,"")
+--~ end
+--~
+--~ local function injectspans(head)
+--~ for n in traverse_nodes(head) do
+--~ local id = n.id
+--~ if id == disc then
+--~ local r, p = n.replace, n.pre
+--~ if r and p then
+--~ local str = compact(r)
+--~ local hsh = hyphenated[str]
+--~ if not hsh then
+--~ hsh = #codes + 1
+--~ hyphenated[str] = hsh
+--~ codes[hsh] = str
+--~ end
+--~ n[a_hyphenated] = hsh
+--~ end
+--~ elseif id == hlist_code or id == vlist_code then
+--~ injectspans(n.list)
+--~ end
+--~ end
+--~ return head, true
+--~ end
+--~
+--~ nodes.injectspans = injectspans
+--~
+--~ tasks.appendaction("processors", "words", "nodes.injectspans")
+--~
+--~ local function injectspans(head)
+--~ for n in traverse_nodes(head) do
+--~ local id = n.id
+--~ if id == disc then
+--~ local a = n[a_hyphenated]
+--~ if a then
+--~ local str = codes[a]
+--~ local b = new_pdfliteral(format("/Span << /ActualText %s >> BDC", lpdf.tosixteen(str)))
+--~ local e = new_pdfliteral("EMC")
+--~ node.insert_before(head,n,b)
+--~ node.insert_after(head,n,e)
+--~ end
+--~ elseif id == hlist_code or id == vlist_code then
+--~ injectspans(n.list)
+--~ end
+--~ end
+--~ end
diff --git a/tex/context/base/node-aux.lua b/tex/context/base/node-aux.lua
index 443c78547..e3fc7ad6f 100644
--- a/tex/context/base/node-aux.lua
+++ b/tex/context/base/node-aux.lua
@@ -43,7 +43,7 @@ local unsetvalue = attributes.unsetvalue
local current_font = font.current
-local texgetbox = tex.getbox
+local texbox = tex.box
local report_error = logs.reporter("node-aux:error")
@@ -195,7 +195,7 @@ function nodes.firstcharacter(n,untagged) -- tagged == subtype > 255
end
function nodes.firstcharinbox(n)
- local l = texgetbox(n).list
+ local l = texbox[n].list
if l then
for g in traverse_id(glyph_code,l) do
return g.char
@@ -370,21 +370,20 @@ end
nodes.locate = locate
--- I have no use for this yet:
---
--- \skip0=10pt plus 2pt minus 2pt
--- \cldcontext{"\letterpercent p",tex.stretch_amount(tex.skip[0],1000)} -- 14.30887pt
---
--- local gluespec_code = nodes.nodecodes.gluespec
---
--- function tex.badness_to_ratio(badness)
--- return (badness/100)^(1/3)
--- end
---
--- function tex.stretch_amount(skip,badness)
--- if skip.id == gluespec_code then
--- return skip.width + (badness and (badness/100)^(1/3) or 1) * skip.stretch
--- else
--- return 0
--- end
--- end
+function nodes.concat(list)
+ local head, tail
+ for i=1,#list do
+ local li = list[i]
+ if not li then
+ -- skip
+ elseif head then
+ tail.next = li
+ li.prev = tail
+ tail = li.next and slide_nodes(li) or li
+ else
+ head = li
+ tail = li.next and slide_nodes(li) or li
+ end
+ end
+ return head, tail
+end
diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua
index 63a5ef83e..2e62ebcb5 100644
--- a/tex/context/base/node-fin.lua
+++ b/tex/context/base/node-fin.lua
@@ -41,12 +41,92 @@ local unsetvalue = attributes.unsetvalue
-- these two will be like trackers
-function states.enabletriggering () triggering = true end
-function states.disabletriggering() triggering = false end
+function states.enabletriggering()
+ triggering = true
+end
+function states.disabletriggering()
+ triggering = false
+end
-nodes.plugindata = nil
+-- the following code is no longer needed due to the new backend
+-- but we keep it around for a while as an example
+--
+-- states.collected = states.collected or { }
+--
+-- storage.register("states/collected", states.collected, "states.collected")
+--
+-- local collected = states.collected
+--
+-- function states.collect(str)
+-- collected[#collected+1] = str
+-- end
+--
+-- function states.flush()
+-- if #collected > 0 then
+-- for i=1,#collected do
+-- context(collected[i]) -- we're in context mode anyway
+-- end
+-- collected = { }
+-- states.collected = collected
+-- end
+-- end
+--
+-- function states.check()
+-- logs.report("states",concat(collected,"\n"))
+-- end
+
+-- we used to do the main processor loop here and call processor for each node
+-- but eventually this was too much a slow down (1 sec on 23 for 120 pages mk)
+-- so that we moved looping to the processor itself; this may lead to a bit of
+-- duplicate code once that we have more state handlers
--- inheritance: -0x7FFFFFFF -- we can best use nil and skip !
+-- local function process_attribute(head,plugin) -- head,attribute,enabled,initializer,resolver,processor,finalizer
+-- local namespace = plugin.namespace
+-- if namespace.enabled ~= false then -- this test will go away
+-- starttiming(attributes) -- in principle we could delegate this to the main caller
+-- local done, used, ok = false, nil, false
+-- local attribute = namespace.attribute or numbers[plugin.name] -- todo: plugin.attribute
+-- local processor = plugin.processor
+-- if processor then
+-- local initializer = plugin.initializer
+-- local resolver = plugin.resolver
+-- local inheritance = (resolver and resolver()) or nil -- -0x7FFFFFFF -- we can best use nil and skip !
+-- if initializer then
+-- initializer(namespace,attribute,head)
+-- end
+-- head, ok = processor(namespace,attribute,head,inheritance)
+-- if ok then
+-- local finalizer = plugin.finalizer
+-- if finalizer then
+-- head, ok, used = finalizer(namespace,attribute,head)
+-- if used then
+-- local flusher = plugin.flusher
+-- if flusher then
+-- head = flusher(namespace,attribute,head,used)
+-- end
+-- end
+-- end
+-- done = true
+-- end
+-- end
+-- stoptiming(attributes)
+-- return head, done
+-- else
+-- return head, false
+-- end
+-- end
+--
+-- function nodes.installattributehandler(plugin) -- we need to avoid this nested function
+-- return function(head)
+-- return process_attribute(head,plugin)
+-- end
+-- end
+
+-- An experiment: lean and mean functions. It is not really faster but
+-- with upcoming functionality it might make a difference, e.g. features
+-- like 'casing' and 'italics' can be called a lot so there it makes sense.
+
+nodes.plugindata = nil
local template = [[
local plugin = nodes.plugindata
@@ -66,10 +146,8 @@ if not processor then
elseif initializer or finalizer or resolver then
return function(head)
starttiming(attributes)
- local done, used, ok, inheritance = false, nil, false, nil
- if resolver then
- inheritance = resolver()
- end
+ local done, used, ok = false, nil, false
+ local inheritance = (resolver and resolver()) or nil -- -0x7FFFFFFF -- we can best use nil and skip !
if initializer then
initializer(namespace,attribute,head)
end
@@ -150,6 +228,309 @@ end
-- we need to deal with literals too (reset as well as oval)
-- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then
+-- local function process(namespace,attribute,head,inheritance,default) -- one attribute
+-- local stack, done = head, false
+-- while stack do
+-- local id = stack.id
+-- if id == glyph_code or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current ~= c then
+-- head = insert_node_before(head,stack,copy_node(nsdata[c]))
+-- current = c
+-- done = true
+-- end
+-- -- here ? compare selective
+-- if id == glue_code then --leader
+-- -- same as *list
+-- local content = stack.leader
+-- if content then
+-- local savedcurrent = current
+-- local ci = content.id
+-- if ci == hlist_code or ci == vlist_code then
+-- -- else we reset inside a box unneeded, okay, the downside is
+-- -- that we trigger color in each repeated box, so there is room
+-- -- for improvement here
+-- current = 0
+-- end
+-- local ok = false
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- current = savedcurrent
+-- done = done or ok
+-- end
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current = 0
+-- done = true
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+-- local ok = false
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.list, ok = process(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.list, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.list, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- done = done or ok
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- return head, done
+-- end
+
+-- local function process(namespace,attribute,head,inheritance,default) -- one attribute
+-- local stack, done = head, false
+
+-- local function check()
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current ~= c then
+-- head = insert_node_before(head,stack,copy_node(nsdata[c]))
+-- current = c
+-- done = true
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current = 0
+-- done = true
+-- end
+-- return c
+-- end
+
+-- local function nested(content)
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- return process(namespace,attribute,content,inheritance,outer)
+-- else
+-- return process(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- return process(namespace,attribute,content,inheritance,default)
+-- end
+-- end
+
+-- while stack do
+-- local id = stack.id
+-- if id == glyph_code then
+-- check()
+-- elseif id == glue_code then
+-- local content = stack.leader
+-- if content and check() then
+-- local savedcurrent = current
+-- local ci = content.id
+-- if ci == hlist_code or ci == vlist_code then
+-- -- else we reset inside a box unneeded, okay, the downside is
+-- -- that we trigger color in each repeated box, so there is room
+-- -- for improvement here
+-- current = 0
+-- end
+
+-- local ok = false
+-- stack.leader, ok = nested(content)
+-- done = done or ok
+
+-- current = savedcurrent
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+
+-- local ok = false
+-- stack.list, ok = nested(content)
+-- done = done or ok
+
+-- end
+-- elseif id == rule_code then
+-- if stack.width ~= 0 then
+-- check()
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- return head, done
+-- end
+
+-- local function process(namespace,attribute,head,inheritance,default) -- one attribute
+-- local stack, done = head, false
+-- while stack do
+-- local id = stack.id
+-- if id == glyph_code then
+-- -- begin of check
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current ~= c then
+-- head = insert_node_before(head,stack,copy_node(nsdata[c]))
+-- current = c
+-- done = true
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current = 0
+-- done = true
+-- end
+-- -- end of check
+-- elseif id == glue_code then
+-- local content = stack.leader
+-- if content then
+-- -- begin of check
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current ~= c then
+-- head = insert_node_before(head,stack,copy_node(nsdata[c]))
+-- current = c
+-- done = true
+-- end
+-- -- begin special to this check
+-- local savedcurrent = current
+-- local ci = content.id
+-- if ci == hlist_code or ci == vlist_code then
+-- -- else we reset inside a box unneeded, okay, the downside is
+-- -- that we trigger color in each repeated box, so there is room
+-- -- for improvement here
+-- current = 0
+-- end
+-- -- begin nested --
+-- local ok = false
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.leader, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- -- end nested --
+-- done = done or ok
+-- current = savedcurrent
+-- -- end special to this check
+-- elseif default and inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current = 0
+-- done = true
+-- end
+-- -- end of check
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+-- -- begin nested --
+-- local ok
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.list, ok = process(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.list, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.list, ok = process(namespace,attribute,content,inheritance,default)
+-- end
+-- -- end nested --
+-- done = done or ok
+-- end
+-- elseif id == rule_code then
+-- if stack.width ~= 0 then
+-- -- begin of check
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current ~= c then
+-- head = insert_node_before(head,stack,copy_node(nsdata[c]))
+-- current = c
+-- done = true
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- head = insert_node_before(head,stack,copy_node(nsdata[default]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current = 0
+-- done = true
+-- end
+-- -- end of check
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- return head, done
+-- end
+
local function process(namespace,attribute,head,inheritance,default) -- one attribute
local stack = head
local done = false
@@ -252,6 +633,184 @@ states.process = process
-- state changes while the main state stays the same (like two glyphs following
-- each other with the same color but different color spaces e.g. \showcolor)
+-- local function selective(namespace,attribute,head,inheritance,default) -- two attributes
+-- local stack, done = head, false
+-- while stack do
+-- local id = stack.id
+-- -- we need to deal with literals too (reset as well as oval)
+-- -- if id == glyph_code or (id == whatsit_code and stack.subtype == pdfliteral_code) or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+-- if id == glyph_code -- or id == disc_code
+-- or (id == rule_code and stack.width ~= 0) or (id == glue_code and stack.leader) then -- or disc_code
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- local data = nsdata[default]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = default
+-- done = true
+-- end
+-- else
+-- local s = stack[nsselector]
+-- if current ~= c or current_selector ~= s then
+-- local data = nsdata[c]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = c
+-- current_selector = s
+-- done = true
+-- end
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- local data = nsdata[default]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current, current_selector, done = 0, 0, true
+-- end
+-- if id == glue_code then -- leader
+-- -- same as *list
+-- local content = stack.leader
+-- if content then
+-- local savedcurrent = current
+-- local ci = content.id
+-- if ci == hlist_code or ci == vlist_code then
+-- -- else we reset inside a box unneeded, okay, the downside is
+-- -- that we trigger color in each repeated box, so there is room
+-- -- for improvement here
+-- current = 0
+-- end
+-- local ok = false
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.leader, ok = selective(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.leader, ok = selective(namespace,attribute,content,inheritance,default)
+-- end
+-- current = savedcurrent
+-- done = done or ok
+-- end
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+-- local ok = false
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- stack.list, ok = selective(namespace,attribute,content,inheritance,outer)
+-- else
+-- stack.list, ok = selective(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- stack.list, ok = selective(namespace,attribute,content,inheritance,default)
+-- end
+-- done = done or ok
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- return head, done
+-- end
+
+-- local function selective(namespace,attribute,head,inheritance,default) -- two attributes
+-- local stack, done = head, false
+
+-- local function check()
+-- local c = stack[attribute]
+-- if c then
+-- if default and c == inheritance then
+-- if current ~= default then
+-- local data = nsdata[default]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = default
+-- done = true
+-- end
+-- else
+-- local s = stack[nsselector]
+-- if current ~= c or current_selector ~= s then
+-- local data = nsdata[c]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = c
+-- current_selector = s
+-- done = true
+-- end
+-- end
+-- elseif default and inheritance then
+-- if current ~= default then
+-- local data = nsdata[default]
+-- head = insert_node_before(head,stack,copy_node(data[nsforced or stack[nsselector] or nsselector]))
+-- current = default
+-- done = true
+-- end
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- current, current_selector, done = 0, 0, true
+-- end
+-- return c
+-- end
+
+-- local function nested(content)
+-- if nstrigger and stack[nstrigger] then
+-- local outer = stack[attribute]
+-- if outer ~= inheritance then
+-- return selective(namespace,attribute,content,inheritance,outer)
+-- else
+-- return selective(namespace,attribute,content,inheritance,default)
+-- end
+-- else
+-- return selective(namespace,attribute,content,inheritance,default)
+-- end
+-- end
+
+-- while stack do
+-- local id = stack.id
+-- if id == glyph_code then
+-- check()
+-- elseif id == glue_code then
+-- local content = stack.leader
+-- if content and check() then
+-- -- local savedcurrent = current
+-- -- local ci = content.id
+-- -- if ci == hlist_code or ci == vlist_code then
+-- -- -- else we reset inside a box unneeded, okay, the downside is
+-- -- -- that we trigger color in each repeated box, so there is room
+-- -- -- for improvement here
+-- -- current = 0
+-- -- end
+
+-- local ok = false
+-- stack.leader, ok = nested(content)
+-- done = done or ok
+
+-- -- current = savedcurrent
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+
+-- local ok = false
+-- stack.list, ok = nested(content)
+-- done = done or ok
+
+-- end
+-- elseif id == rule_code then
+-- if stack.width ~= 0 then
+-- check()
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- return head, done
+-- end
+
local function selective(namespace,attribute,head,inheritance,default) -- two attributes
local stack = head
local done = false
@@ -355,6 +914,77 @@ states.selective = selective
-- Todo: make a better stacker. Keep track (in attribute) about nesting level. Not
-- entirely trivial and a generic solution is nicer (compares to the exporter).
+-- local function stacked(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
+-- local stack, done = head, false
+-- local current, depth = default or 0, 0
+--
+-- local function check()
+-- local a = stack[attribute]
+-- if a then
+-- if current ~= a then
+-- head = insert_node_before(head,stack,copy_node(nsdata[a]))
+-- depth = depth + 1
+-- current, done = a, true
+-- end
+-- elseif default > 0 then
+-- --
+-- elseif current > 0 then
+-- head = insert_node_before(head,stack,copy_node(nsnone))
+-- depth = depth - 1
+-- current, done = 0, true
+-- end
+-- return a
+-- end
+--
+-- while stack do
+-- local id = stack.id
+-- if id == glyph_code then
+-- check()
+-- elseif id == glue_code then
+-- local content = stack.leader
+-- if content and check() then
+-- local ok = false
+-- stack.leader, ok = stacked(namespace,attribute,content,current)
+-- done = done or ok
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = stack.list
+-- if content then
+-- -- the problem is that broken lines gets the attribute which can be a later one
+-- if nslistwise then
+-- local a = stack[attribute]
+-- if a and current ~= a and nslistwise[a] then -- viewerlayer / needs checking, see below
+-- local p = current
+-- current, done = a, true
+-- head = insert_node_before(head,stack,copy_node(nsdata[a]))
+-- stack.list = stacked(namespace,attribute,content,current)
+-- head, stack = insert_node_after(head,stack,copy_node(nsnone))
+-- current = p
+-- else
+-- local ok = false
+-- stack.list, ok = stacked(namespace,attribute,content,current)
+-- done = done or ok
+-- end
+-- else
+-- local ok = false
+-- stack.list, ok = stacked(namespace,attribute,content,current)
+-- done = done or ok
+-- end
+-- end
+-- elseif id == rule_code then
+-- if stack.width ~= 0 then
+-- check()
+-- end
+-- end
+-- stack = stack.next
+-- end
+-- while depth > 0 do
+-- head = insert_node_after(head,stack,copy_node(nsnone))
+-- depth = depth - 1
+-- end
+-- return head, done
+-- end
+
local function stacked(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
local stack = head
local done = false
@@ -436,6 +1066,76 @@ states.stacked = stacked
-- experimental
+-- local function stacker(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
+-- nsbegin()
+-- local current, previous, done, okay = head, head, false, false
+-- local attrib = default or unsetvalue
+--
+-- local function check()
+-- local a = current[attribute] or unsetvalue
+-- if a ~= attrib then
+-- local n = nsstep(a)
+-- if n then
+-- -- !!!! TEST CODE !!!!
+-- -- head = insert_node_before(head,current,copy_node(nsdata[tonumber(n)])) -- a
+-- head = insert_node_before(head,current,n) -- a
+-- end
+-- attrib, done, okay = a, true, true
+-- end
+-- return a
+-- end
+--
+-- while current do
+-- local id = current.id
+-- if id == glyph_code then
+-- check()
+-- elseif id == glue_code then
+-- local content = current.leader
+-- if content and check() then
+-- -- tricky as a leader has to be a list so we cannot inject before
+-- local _, ok = stacker(namespace,attribute,content,attrib)
+-- done = done or ok
+-- end
+-- elseif id == hlist_code or id == vlist_code then
+-- local content = current.list
+-- if not content then
+-- -- skip
+-- elseif nslistwise then
+-- local a = current[attribute]
+-- if a and attrib ~= a and nslistwise[a] then -- viewerlayer
+-- done = true
+-- head = insert_node_before(head,current,copy_node(nsdata[a]))
+-- current.list = stacker(namespace,attribute,content,a)
+-- head, current = insert_node_after(head,current,copy_node(nsnone))
+-- else
+-- local ok = false
+-- current.list, ok = stacker(namespace,attribute,content,attrib)
+-- done = done or ok
+-- end
+-- else
+-- local ok = false
+-- current.list, ok = stacker(namespace,attribute,content,default)
+-- done = done or ok
+-- end
+-- elseif id == rule_code then
+-- if current.width ~= 0 then
+-- check()
+-- end
+-- end
+-- previous = current
+-- current = current.next
+-- end
+-- if okay then
+-- local n = nsend()
+-- if n then
+-- -- !!!! TEST CODE !!!!
+-- -- head = insert_node_after(head,previous,copy_node(nsdata[tostring(n)]))
+-- head = insert_node_after(head,previous,n)
+-- end
+-- end
+-- return head, done
+-- end
+
local function stacker(namespace,attribute,head,default) -- no triggering, no inheritance, but list-wise
nsbegin()
local current = head
diff --git a/tex/context/base/node-fin.mkiv b/tex/context/base/node-fin.mkiv
index 2eb033fc1..09bac6c08 100644
--- a/tex/context/base/node-fin.mkiv
+++ b/tex/context/base/node-fin.mkiv
@@ -23,12 +23,8 @@
% we might have two variants at some point (efficiency)
-\unexpanded\def\finalizeobjectbox #1{\ctxcommand{finalizebox(\number#1)}}
-\unexpanded\def\finalizeshipoutbox#1{\ctxcommand{finalizebox(\number#1)}}
-
-% Experimental (for Aditya):
-
-\unexpanded\def\cleanupbox#1{\ctxcommand{cleanupbox(\number#1)}}
+\def\finalizeobjectbox #1{\ctxcommand{finalizebox(\number#1)}}
+\def\finalizeshipoutbox#1{\ctxcommand{finalizebox(\number#1)}}
% Tricky stuff: this might become obsolete.
diff --git a/tex/context/base/node-fnt.lua b/tex/context/base/node-fnt.lua
index 2f59d513c..54359117e 100644
--- a/tex/context/base/node-fnt.lua
+++ b/tex/context/base/node-fnt.lua
@@ -30,7 +30,6 @@ local nodecodes = nodes.nodecodes
local handlers = nodes.handlers
local glyph_code = nodecodes.glyph
-local disc_code = nodecodes.disc
local setmetatableindex = table.setmetatableindex
@@ -49,31 +48,12 @@ local run = 0
local setfontdynamics = { }
local fontprocesses = { }
--- setmetatableindex(setfontdynamics, function(t,font)
--- local tfmdata = fontdata[font]
--- local shared = tfmdata.shared
--- local v = shared and shared.dynamics and otf.setdynamics or false
--- t[font] = v
--- return v
--- end)
-
setmetatableindex(setfontdynamics, function(t,font)
local tfmdata = fontdata[font]
local shared = tfmdata.shared
- local f = shared and shared.dynamics and otf.setdynamics or false
- if f then
- local v = { }
- t[font] = v
- setmetatableindex(v,function(t,k)
- local v = f(font,k)
- t[k] = v
- return v
- end)
- return v
- else
- t[font] = false
- return false
- end
+ local v = shared and shared.dynamics and otf.setdynamics or false
+ t[font] = v
+ return v
end)
setmetatableindex(fontprocesses, function(t,font)
@@ -92,18 +72,11 @@ end)
fonts.hashes.setdynamics = setfontdynamics
fonts.hashes.processes = fontprocesses
--- if we forget about basemode we don't need to test too much here and we can consider running
--- over sub-ranges .. this involves a bit more initializations but who cares .. in that case we
--- also need to use the stop criterium (we already use head too) ... we cannot use traverse
--- then, so i'll test it on some local clone first ... the only pitfall is changed directions
--- 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
-
function handlers.characters(head)
-- either next or not, but definitely no already processed list
starttiming(nodes)
- local usedfonts, attrfonts = { }, { }
- local a, u, prevfont, prevattr, done = 0, 0, nil, 0, false
+ local usedfonts, attrfonts, done = { }, { }, false
+ local a, u, prevfont, prevattr = 0, 0, nil, 0
if trace_fontrun then
run = run + 1
report_fonts()
@@ -115,11 +88,9 @@ function handlers.characters(head)
if id == glyph_code then
local font = n.font
local attr = n[0] or 0
- report_fonts("font %03i, dynamic %03i, glyph %C",font,attr,n.char)
- elseif id == disc_code then
- report_fonts("[disc] %s",nodes.listtoutf(n,true,false,n))
+ report_fonts("font %03i, dynamic %03i, glyph %s",font,attr,utf.char(n.char))
else
- report_fonts("[%s]",nodecodes[id])
+ report_fonts("[%s]",nodecodes[n.id])
end
n = n.next
end
@@ -136,10 +107,15 @@ function handlers.characters(head)
attrfonts[font] = used
end
if not used[attr] then
- local fd = setfontdynamics[font]
- if fd then
- used[attr] = fd[attr]
- a = a + 1
+ local sd = setfontdynamics[font]
+ if sd then -- always true ?
+ local d = sd(font,attr) -- can we cache this one?
+ if d then
+ used[attr] = d
+ a = a + 1
+ else
+ -- can't happen ... otherwise best use nil/false distinction
+ end
end
end
else
@@ -149,7 +125,9 @@ function handlers.characters(head)
if fp then
usedfonts[font] = fp
u = u + 1
- end
+ else
+ -- can't happen ... otherwise best use nil/false distinction
+ end
end
end
prevfont = font
@@ -163,25 +141,34 @@ function handlers.characters(head)
report_fonts("dynamics: %s",(a > 0 and concat(keys(attrfonts)," ")) or "none")
report_fonts()
end
- -- in context we always have at least 2 processors
if u == 0 then
-- skip
elseif u == 1 then
local font, processors = next(usedfonts)
- for i=1,#processors do
- local h, d = processors[i](head,font,0)
- if d then
- head = h or head
- done = true
+ local n = #processors
+ if n > 0 then
+ local h, d = processors[1](head,font,0)
+ head = h or head
+ done = done or d
+ if n > 1 then
+ for i=2,n do
+ local h, d = processors[i](head,font,0)
+ head = h or head
+ done = done or d
+ end
end
end
else
for font, processors in next, usedfonts do
- for i=1,#processors do
- local h, d = processors[i](head,font,0)
- if d then
+ local n = #processors
+ local h, d = processors[1](head,font,0)
+ head = h or head
+ done = done or d
+ if n > 1 then
+ for i=2,n do
+ local h, d = processors[i](head,font,0)
head = h or head
- done = true
+ done = done or d
end
end
end
@@ -191,22 +178,38 @@ function handlers.characters(head)
elseif a == 1 then
local font, dynamics = next(attrfonts)
for attribute, processors in next, dynamics do -- attr can switch in between
- for i=1,#processors do
- local h, d = processors[i](head,font,attribute)
- if d then
- head = h or head
- done = true
+ local n = #processors
+ if n == 0 then
+ report_fonts("no processors associated with dynamic %s",attribute)
+ else
+ local h, d = processors[1](head,font,attribute)
+ head = h or head
+ done = done or d
+ if n > 1 then
+ for i=2,n do
+ local h, d = processors[i](head,font,attribute)
+ head = h or head
+ done = done or d
+ end
end
end
end
else
for font, dynamics in next, attrfonts do
for attribute, processors in next, dynamics do -- attr can switch in between
- for i=1,#processors do
- local h, d = processors[i](head,font,attribute)
- if d then
- head = h or head
- done = true
+ local n = #processors
+ if n == 0 then
+ report_fonts("no processors associated with dynamic %s",attribute)
+ else
+ local h, d = processors[1](head,font,attribute)
+ head = h or head
+ done = done or d
+ if n > 1 then
+ for i=2,n do
+ local h, d = processors[i](head,font,attribute)
+ head = h or head
+ done = done or d
+ end
end
end
end
@@ -219,177 +222,5 @@ function handlers.characters(head)
return head, true
end
--- local formatters = string.formatters
-
--- local function make(processors,font,attribute)
--- _G.__temp = processors
--- local t = { }
--- for i=1,#processors do
--- if processors[i] then
--- t[#t+1] = formatters["local p_%s = _G.__temp[%s]"](i,i)
--- end
--- end
--- t[#t+1] = "return function(head,done)"
--- if #processors == 1 then
--- t[#t+1] = formatters["return p_%s(head,%s,%s)"](1,font,attribute or 0)
--- else
--- for i=1,#processors do
--- if processors[i] then
--- t[#t+1] = formatters["local h,d=p_%s(head,%s,%s) if d then head=h or head done=true end"](i,font,attribute or 0)
--- end
--- end
--- t[#t+1] = "return head, done"
--- end
--- t[#t+1] = "end"
--- t = concat(t,"\n")
--- t = load(t)(processors)
--- _G.__temp = nil
--- return t
--- end
-
--- setmetatableindex(fontprocesses, function(t,font)
--- local tfmdata = fontdata[font]
--- local shared = tfmdata.shared -- we need to check shared, only when same features
--- local processes = shared and shared.processes
--- if processes and #processes > 0 then
--- processes = make(processes,font,0)
--- t[font] = processes
--- return processes
--- else
--- t[font] = false
--- return false
--- end
--- end)
-
--- setmetatableindex(setfontdynamics, function(t,font)
--- local tfmdata = fontdata[font]
--- local shared = tfmdata.shared
--- local f = shared and shared.dynamics and otf.setdynamics or false
--- if f then
--- local v = { }
--- t[font] = v
--- setmetatableindex(v,function(t,k)
--- local v = f(font,k)
--- v = make(v,font,k)
--- t[k] = v
--- return v
--- end)
--- return v
--- else
--- t[font] = false
--- return false
--- end
--- end)
-
--- function handlers.characters(head)
--- -- either next or not, but definitely no already processed list
--- starttiming(nodes)
--- local usedfonts, attrfonts
--- local a, u, prevfont, prevattr, done = 0, 0, nil, 0, false
--- if trace_fontrun then
--- run = run + 1
--- report_fonts()
--- report_fonts("checking node list, run %s",run)
--- report_fonts()
--- local n = head
--- while n do
--- local id = n.id
--- if id == glyph_code then
--- local font = n.font
--- local attr = n[0] or 0
--- report_fonts("font %03i, dynamic %03i, glyph %s",font,attr,utf.char(n.char))
--- else
--- report_fonts("[%s]",nodecodes[n.id])
--- end
--- n = n.next
--- end
--- end
--- for n in traverse_id(glyph_code,head) do
--- -- if n.subtype<256 then -- all are 1
--- local font = n.font
--- local attr = n[0] or 0 -- zero attribute is reserved for fonts in context
--- if font ~= prevfont or attr ~= prevattr then
--- if attr > 0 then
--- if not attrfonts then
--- attrfonts = {
--- [font] = {
--- [attr] = setfontdynamics[font][attr]
--- }
--- }
--- a = 1
--- else
--- local used = attrfonts[font]
--- if not used then
--- attrfonts[font] = {
--- [attr] = setfontdynamics[font][attr]
--- }
--- a = a + 1
--- elseif not used[attr] then
--- used[attr] = setfontdynamics[font][attr]
--- a = a + 1
--- end
--- end
--- else
--- if not usedfonts then
--- local fp = fontprocesses[font]
--- if fp then
--- usedfonts = {
--- [font] = fp
--- }
--- u = 1
--- end
--- else
--- local used = usedfonts[font]
--- if not used then
--- local fp = fontprocesses[font]
--- if fp then
--- usedfonts[font] = fp
--- u = u + 1
--- end
--- end
--- end
--- end
--- prevfont = font
--- prevattr = attr
--- end
--- -- end
--- end
--- if trace_fontrun then
--- 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()
--- end
--- if not usedfonts then
--- -- skip
--- elseif u == 1 then
--- local font, processors = next(usedfonts)
--- head, done = processors(head,done)
--- else
--- for font, processors in next, usedfonts do
--- head, done = processors(head,done)
--- end
--- end
--- if not attrfonts then
--- -- skip
--- elseif a == 1 then
--- local font, dynamics = next(attrfonts)
--- for attribute, processors in next, dynamics do
--- head, done = processors(head,done)
--- end
--- else
--- for font, dynamics in next, attrfonts do
--- for attribute, processors in next, dynamics do
--- head, done = processors(head,done)
--- end
--- end
--- end
--- stoptiming(nodes)
--- if trace_characters then
--- nodes.report(head,done)
--- end
--- return head, true
--- end
-
handlers.protectglyphs = node.protect_glyphs
handlers.unprotectglyphs = node.unprotect_glyphs
diff --git a/tex/context/base/node-ini.lua b/tex/context/base/node-ini.lua
index 652b46caf..5a3986c3a 100644
--- a/tex/context/base/node-ini.lua
+++ b/tex/context/base/node-ini.lua
@@ -13,10 +13,13 @@ modules.
-- this module is being reconstructed
-local next, type, tostring = next, type, tostring
-local gsub = string.gsub
+local next, type = next, type
+local format, match, gsub = string.format, string.match, string.gsub
local concat, remove = table.concat, table.remove
-local sortedhash, sortedkeys, swapped = table.sortedhash, table.sortedkeys, table.swapped
+local sortedhash, sortedkeys, swapped, tohash = table.sortedhash, table.sortedkeys, table.swapped, table.tohash
+local utfchar = utf.char
+local lpegmatch = lpeg.match
+local formatcolumns = utilities.formatters.formatcolumns
--[[ldx--
Access to nodes is what gives its power. Here we
@@ -51,12 +54,20 @@ into the engine, but this is a not so natural extension.
also ignore the empty nodes. [This is obsolete!]
--ldx]]--
-nodes = nodes or { }
-local nodes = nodes
-nodes.handlers = nodes.handlers or { }
+local traverse = node.traverse
+local traverse_id = node.traverse_id
+local free_node = node.free
+local remove_node = node.remove
+local insert_node_before = node.insert_before
+local insert_node_after = node.insert_after
+local node_fields = node.fields
-local allocate = utilities.storage.allocate
-local formatcolumns = utilities.formatters.formatcolumns
+local allocate = utilities.storage.allocate
+
+nodes = nodes or { }
+local nodes = nodes
+
+nodes.handlers = nodes.handlers or { }
-- there will be more of this:
@@ -92,7 +103,7 @@ local penaltycodes = allocate { -- unfortunately not used
table.setmetatableindex(penaltycodes,function(t,k) return "userpenalty" end) -- not used anyway
-local noadcodes = allocate { -- simple nodes
+local noadcodes = allocate {
[ 0] = "ord",
[ 1] = "opdisplaylimits",
[ 2] = "oplimits",
@@ -159,20 +170,6 @@ local disccodes = allocate {
[5] = "second", -- hard second item
}
-local accentcodes = allocate {
- [0] = "bothflexible",
- [1] = "fixedtop",
- [2] = "fixedbottom",
- [3] = "fixedboth",
-}
-
-local fencecodes = allocate {
- [0] = "unset",
- [1] = "left",
- [2] = "middle",
- [3] = "right",
-}
-
local function simplified(t)
local r = { }
for k, v in next, t do
@@ -196,8 +193,6 @@ mathcodes = allocate(swapped(mathcodes,mathcodes))
fillcodes = allocate(swapped(fillcodes,fillcodes))
margincodes = allocate(swapped(margincodes,margincodes))
disccodes = allocate(swapped(disccodes,disccodes))
-accentcodes = allocate(swapped(accentcodes,accentcodes))
-fencecodes = allocate(swapped(fencecodes,fencecodes))
nodes.skipcodes = skipcodes nodes.gluecodes = skipcodes -- more official
nodes.noadcodes = noadcodes
@@ -211,8 +206,6 @@ nodes.mathcodes = mathcodes
nodes.fillcodes = fillcodes
nodes.margincodes = margincodes
nodes.disccodes = disccodes nodes.discretionarycodes = disccodes
-nodes.accentcodes = accentcodes
-nodes.fencecodes = fencecodes
listcodes.row = listcodes.alignment
listcodes.column = listcodes.alignment
@@ -234,8 +227,6 @@ nodes.codes = allocate { -- mostly for listing
margin = margincodes,
disc = disccodes,
whatsit = whatcodes,
- accent = accentcodes,
- fence = fencecodes,
}
local report_codes = logs.reporter("nodes","codes")
@@ -257,4 +248,174 @@ function nodes.showcodes()
end
end
+local whatsit_node = nodecodes.whatsit
+
+local messyhack = tohash { -- temporary solution
+ nodecodes.attributelist,
+ nodecodes.attribute,
+ nodecodes.gluespec,
+ nodecodes.action,
+}
+
+function nodes.fields(n)
+ local id = n.id
+ if id == whatsit_node then
+ return node_fields(id,n.subtype)
+ else
+ local t = node_fields(id)
+ if messyhack[id] then
+ for i=1,#t do
+ if t[i] == "subtype" then
+ remove(t,i)
+ break
+ end
+ end
+ end
+ return t
+ end
+end
+
trackers.register("system.showcodes", nodes.showcodes)
+
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glue_code = nodecodes.glue
+
+-- if t.id == glue_code then
+-- local s = t.spec
+-- print(t)
+-- print(s,s and s.writable)
+-- if s and s.writable then
+-- free_node(s)
+-- end
+-- t.spec = nil
+-- end
+
+local function remove(head, current, free_too)
+ local t = current
+ head, current = remove_node(head,current)
+ if t then
+ if free_too then
+ free_node(t)
+ t = nil
+ else
+ t.next = nil
+ t.prev = nil
+ end
+ end
+ return head, current, t
+end
+
+nodes.remove = remove
+
+function nodes.delete(head,current)
+ return remove(head,current,true)
+end
+
+nodes.before = insert_node_before
+nodes.after = insert_node_after
+
+-- we need to test this, as it might be fixed now
+
+function nodes.before(h,c,n)
+ if c then
+ if c == h then
+ n.next = h
+ n.prev = nil
+ h.prev = n
+ else
+ local cp = c.prev
+ n.next = c
+ n.prev = cp
+ if cp then
+ cp.next = n
+ end
+ c.prev = n
+ return h, n
+ end
+ end
+ return n, n
+end
+
+function nodes.after(h,c,n)
+ if c then
+ local cn = c.next
+ if cn then
+ n.next = cn
+ cn.prev = n
+ else
+ n.next = nil
+ end
+ c.next = n
+ n.prev = c
+ return h, n
+ end
+ return n, n
+end
+
+-- local h, c = nodes.replace(head,current,new)
+-- local c = nodes.replace(false,current,new)
+-- local c = nodes.replace(current,new)
+
+function nodes.replace(head,current,new) -- no head returned if false
+ if not new then
+ head, current, new = false, head, current
+ end
+ local prev, next = current.prev, current.next
+ if next then
+ new.next = next
+ next.prev = new
+ end
+ if prev then
+ new.prev = prev
+ prev.next = new
+ end
+ if head then
+ if head == current then
+ head = new
+ end
+ free_node(current)
+ return head, new
+ else
+ free_node(current)
+ return new
+ end
+end
+
+-- will move
+
+local function count(stack,flat)
+ local n = 0
+ while stack do
+ local id = stack.id
+ if not flat and id == hlist_code or id == vlist_code then
+ local list = stack.list
+ if list then
+ n = n + 1 + count(list) -- self counts too
+ else
+ n = n + 1
+ end
+ else
+ n = n + 1
+ end
+ stack = stack.next
+ end
+ return n
+end
+
+nodes.count = count
+
+local left, space = lpeg.P("<"), lpeg.P(" ")
+
+local reference = left * (1-left)^0 * left * space^0 * lpeg.C((1-space)^0)
+
+function nodes.reference(n)
+ return lpegmatch(reference,tostring(n))
+end
+
+if not node.next then
+
+ function node.next(n) return n and n.next end
+ function node.prev(n) return n and n.prev end
+
+end
diff --git a/tex/context/base/node-ini.mkiv b/tex/context/base/node-ini.mkiv
index e99653327..39d48a00a 100644
--- a/tex/context/base/node-ini.mkiv
+++ b/tex/context/base/node-ini.mkiv
@@ -18,10 +18,6 @@
\newcount\filterstate \filterstate\plusone % hm, public
\registerctxluafile{node-ini}{1.001}
-\registerctxluafile{node-met}{1.001}
-
-\ctxlua{if nodes.gonuts then context.registerctxluafile("node-nut","1.001") end}
-
\registerctxluafile{node-res}{1.001}
\registerctxluafile{node-dir}{1.001}
\registerctxluafile{node-aux}{1.001}
diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua
index ae48150a6..697370cfb 100644
--- a/tex/context/base/node-inj.lua
+++ b/tex/context/base/node-inj.lua
@@ -11,8 +11,6 @@ if not modules then modules = { } end modules ['node-inj'] = {
-- test fonts. Btw, future versions of luatex will have extended glyph properties
-- that can be of help. Some optimizations can go away when we have faster machines.
--- todo: make a special one for context
-
local next = next
local utfchar = utf.char
@@ -108,7 +106,7 @@ function injections.setkern(current,factor,rlmode,x,tfmchr)
end
end
-function injections.setmark(start,base,factor,rlmode,ba,ma,index,baseismark) -- ba=baseanchor, ma=markanchor
+function injections.setmark(start,base,factor,rlmode,ba,ma,index) -- ba=baseanchor, ma=markanchor
local dx, dy = factor*(ba[1]-ma[1]), factor*(ba[2]-ma[2]) -- the index argument is no longer used but when this
local bound = base[a_markbase] -- fails again we should pass it
local index = 1
@@ -131,7 +129,7 @@ function injections.setmark(start,base,factor,rlmode,ba,ma,index,baseismark) --
base[a_markbase] = bound
start[a_markmark] = bound
start[a_markdone] = index
- marks[bound] = { [index] = { dx, dy, rlmode, baseismark } }
+ marks[bound] = { [index] = { dx, dy, rlmode } }
return dx, dy, bound
end
@@ -385,11 +383,6 @@ function injections.handler(head,where,keep)
else
n.xoffset = p.xoffset - d[1]
end
- local w = n.width
- if w ~= 0 then
- insert_node_before(head,n,newkern(-w/2))
- insert_node_after(head,n,newkern(-w/2))
- end
end
-- --
if mk[p] then
diff --git a/tex/context/base/node-ltp.lua b/tex/context/base/node-ltp.lua
deleted file mode 100644
index 97e61cf18..000000000
--- a/tex/context/base/node-ltp.lua
+++ /dev/null
@@ -1,3207 +0,0 @@
-if not modules then modules = { } end modules ['node-par'] = {
- version = 1.001,
- comment = "companion to node-par.mkiv",
- author = "Hans Hagen",
- copyright = "ConTeXt Development Team",
- license = "see context related readme files",
- comment = "a translation of the built in parbuilder, initial convertsin by Taco Hoekwater",
-}
-
--- todo: remove nest_stack from linebreak.w
--- todo: use ex field as signal (index in ?)
--- todo: attr driven unknown/on/off
--- todo: permit global steps i.e. using an attribute that sets min/max/step and overloads the font parameters
--- todo: split the three passes into three functions
--- todo: simplify the direction stack, no copy needed
--- todo: add more mkiv like tracing
--- todo: add a couple of plugin hooks
--- todo: maybe split expansion code paths
--- todo: fix line numbers (cur_list.pg_field needed)
--- todo: make kerns stretch an option and disable it by default (definitely not shrink)
--- todo: check and improve protrusion
--- todo: arabic etc (we could use pretty large scales there) .. marks and cursive
-
---[[
-
- This code is derived from traditional TeX and has bits of pdfTeX, Aleph (Omega), and of course LuaTeX. So,
- the basic algorithm for sure is not our work. On the other hand, the directional model in LuaTeX is cleaned
- up as is other code. And of course there are hooks for callbacks.
-
- The first version of the code below was a conversion of the C code that in turn was a conversion from the
- original Pascal code. Around September 2008 we experimented with cq. discussed possible approaches to improved
- typesetting of Arabic and as our policy is that extensions happen in Lua this means that we need a parbuilder
- in Lua. Taco's first conversion still looked quite C-ish and in the process of cleaning up we uncovered some odd
- bits and pieces in the original code as well. I did some first cleanup to get rid of C-artefacts, and Taco and I
- spent the usual amount of Skyping to sort out problems. At that point we diverted to other LuaTeX issues.
-
- A while later I decided to pick up this thread and decided to look into better ways to deal with font expansion
- (aka hz). I got it running using a simpler method. One reason why the built-in mechanims is slow is that there is
- lots of redudancy in calculations. Expanded widths are recalculated each time and because the hpakc routine does
- it again that gives some overhead. In the process extra fonts are created with different dimensions so that the
- backend can deal with it. The alternative method doesn't create fonts but passes an expansion factor to the
- pdf generator. The small patch needed for the backend code worked more or less okay but was never intergated into
- LuaTeX due to lack of time.
-
- This all happened in 2010 while listening to Peter Gabriels "Scratch My Back" and Camels "Rayaz" so it was a
- rather relaxed job.
-
- In 2012 I picked up this thread. Because both languages are similar but also quite different it took some time
- to get compatible output. Because the C code uses macros, careful checking was needed. Of course Lua's table model
- and local variables brought some work as well. And still the code looks a bit C-ish. We could not divert too much
- from the original model simply because it's well documented but future versions (or variants) might as well look
- different.
-
- Eventually I'll split this code into passes so that we can better see what happens, but first we need to reach
- a decent level of stability. The current expansion results are not the same as the built-in but that was never
- the objective. It all has to do with slightly different calculations.
-
- The original C-code related to protrusion and expansion is not that efficient as many (redundant) function
- calls take place in the linebreaker and packer. As most work related to fonts is done in the backend, we
- can simply stick to width calculations here. Also, it is no problem at all that we use floating point
- calculations (as Lua has only floats). The final result will look ok as the hpack will nicely compensate
- for rounding errors as it will normally distribute the content well enough. And let's admit: most texies
- won't see it anyway. As long as we're cross platform compatible it's fine.
-
- We use the table checked_expansion to keep track of font related parameters (per paragraph). The table is
- also the signal that we have adjustments > 1. In retrospect one might wonder if adjusting kerns is such a
- good idea because other spacing is also not treated. If we would stick to the regular hpack routine
- we do have to follow the same logic, but I decided to use a Lua hpacker so that constraint went away. And
- anyway, instead of doing a lookup in the kern table (that we don't have in node mode) the set kern value
- is used. Disabling kern scaling will become an option in Luatex some day. You can blame me for all errors
- that crept in and I know that there are some.
-
- To be honest, I slowly start to grasp the magic here as normally I start from scratch when implementing
- something (as it's the only way I can understand things). This time I had a recently acquired stack of
- Porcupine Tree disks to get me through.
-
- Picking up this effort was inspired by discussions between Luigi Scarso and me about efficiency of Lua
- code and we needed some stress tests to compare regular LuaTeX and LuajitTeX. One of the tests was
- processing tufte.tex as that one has lots of hyphenations and is a tough one to get right.
-
- tufte: boxed 1000 times, no flushing in backend:
-
- \testfeatureonce{1000}{\setbox0\hbox{\tufte}}
- \testfeatureonce{1000}{\setbox0\vbox{\tufte}}
- \startparbuilder[basic]\testfeatureonce{1000}{\setbox0\vbox{\tufte}}\stopparbuilder
-
- method normal hz comment
-
- luatex tex hbox 9.64 9.64 baseline font feature processing, hyphenation etc: 9.74
- tex vbox 9.84 10.16 0.20 linebreak / 0.52 with hz -> 0.32 hz overhead (150pct more)
- lua vbox 17.28 18.43 7.64 linebreak / 8.79 with hz -> 1.33 hz overhead ( 20pct more)
-
- luajittex tex hbox 6.33 6.33 baseline font feature processing, hyphenation etc: 6.33
- tex vbox 6.53 6.81 0.20 linebreak / 0.48 with hz -> 0.28 hz overhead (expected 0.32)
- lua vbox 11.06 11.81 4.53 linebreak / 5.28 with hz -> 0.75 hz overhead
-
- Interesting is that the runtime for the built-in parbuilder indeed increases much when expansion
- is enabled, but in the Lua variant the extra overhead is way less significant. This means that when we
- retrofit the same approach into the core, the overhead of expansion can be sort of nilled.
-
-]]--
-
-local utfchar = utf.char
-local write, write_nl = texio.write, texio.write_nl
-local sub, format = string.sub, string.format
-local round = math.round
-local insert, remove = table.insert, table.remove
-
-local fonts, nodes, node = fonts, nodes, node
-
-local trace_basic = false trackers.register("builders.paragraphs.basic", function(v) trace_basic = v end)
-local trace_lastlinefit = false trackers.register("builders.paragraphs.lastlinefit", function(v) trace_lastlinefit = v end)
-local trace_adjusting = false trackers.register("builders.paragraphs.adjusting", function(v) trace_adjusting = v end)
-local trace_protruding = false trackers.register("builders.paragraphs.protruding", function(v) trace_protruding = v end)
-local trace_expansion = false trackers.register("builders.paragraphs.expansion", function(v) trace_expansion = v end)
-local trace_quality = false trackers.register("builders.paragraphs.quality", function(v) trace_quality = v end)
-
-local report_parbuilders = logs.reporter("nodes","parbuilders")
-local report_hpackers = logs.reporter("nodes","hpackers")
-
-local calculate_badness = tex.badness
-local texnest = tex.nest
-local texlists = tex.lists
-
--- (t == 0 and 0) or (s <= 0 and 10000) or calculate_badness(t,s)
-
--- local function calculate_badness(t,s)
--- if t == 0 then
--- return 0
--- elseif s <= 0 then
--- return 10000 -- infinite_badness
--- else
--- local r
--- if t <= 7230584 then
--- r = (t * 297) / s
--- elseif s >= 1663497 then
--- r = t / (s / 297)
--- else
--- r = t
--- end
--- if r > 1290 then
--- return 10000 -- infinite_badness
--- else
--- return (r * r * r + 0x20000) / 0x40000
--- end
--- end
--- end
-
-local parbuilders = builders.paragraphs
-local constructors = parbuilders.constructors
-
-local setmetatableindex = table.setmetatableindex
-
-local fonthashes = fonts.hashes
-local fontdata = fonthashes.identifiers
-local chardata = fonthashes.characters
-local quaddata = fonthashes.quads
-local parameters = fonthashes.parameters
-
-local slide_nodes = node.slide
-local new_node = node.new
-local copy_node = node.copy
-local copy_node_list = node.copy_list
-local flush_node = node.free
-local flush_node_list = node.flush_list
-local hpack_nodes = node.hpack
-local xpack_nodes = node.hpack
-local replace_node = nodes.replace
-local insert_node_after = node.insert_after
-local insert_node_before = node.insert_before
-local traverse_by_id = node.traverse_id
-
-local setnodecolor = nodes.tracers.colors.set
-
-local nodepool = nodes.pool
-
-local nodecodes = nodes.nodecodes
-local whatcodes = nodes.whatcodes
-local kerncodes = nodes.kerncodes
-local glyphcodes = nodes.glyphcodes
-local gluecodes = nodes.gluecodes
-local margincodes = nodes.margincodes
-local disccodes = nodes.disccodes
-local mathcodes = nodes.mathcodes
-local fillcodes = nodes.fillcodes
-
-local temp_code = nodecodes.temp
-local glyph_code = nodecodes.glyph
-local ins_code = nodecodes.ins
-local mark_code = nodecodes.mark
-local adjust_code = nodecodes.adjust
-local penalty_code = nodecodes.penalty
-local whatsit_code = nodecodes.whatsit
-local disc_code = nodecodes.disc
-local math_code = nodecodes.math
-local kern_code = nodecodes.kern
-local glue_code = nodecodes.glue
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local unset_code = nodecodes.unset
-local marginkern_code = nodecodes.marginkern
-
-local leaders_code = gluecodes.leaders
-
-local localpar_code = whatcodes.localpar
-local dir_code = whatcodes.dir
-local pdfrefximage_code = whatcodes.pdfrefximage
-local pdfrefxform_code = whatcodes.pdfrefxform
-
-local kerning_code = kerncodes.kerning -- font kern
-local userkern_code = kerncodes.userkern
-
-local ligature_code = glyphcodes.ligature
-
-local stretch_orders = nodes.fillcodes
-
-local leftmargin_code = margincodes.left
-local rightmargin_code = margincodes.right
-
-local automatic_disc_code = disccodes.automatic
-local regular_disc_code = disccodes.regular
-local first_disc_code = disccodes.first
-local second_disc_code = disccodes.second
-
-local endmath_code = mathcodes.endmath
-
-local nosubtype_code = 0
-
-local unhyphenated_code = nodecodes.unhyphenated or 1
-local hyphenated_code = nodecodes.hyphenated or 2
-local delta_code = nodecodes.delta or 3
-local passive_code = nodecodes.passive or 4
-
-local maxdimen = number.maxdimen
-
-local max_halfword = 0x7FFFFFFF
-local infinite_penalty = 10000
-local eject_penalty = -10000
-local infinite_badness = 10000
-local awful_badness = 0x3FFFFFFF
-
-local fit_very_loose_class = 0 -- fitness for lines stretching more than their stretchability
-local fit_loose_class = 1 -- fitness for lines stretching 0.5 to 1.0 of their stretchability
-local fit_decent_class = 2 -- fitness for all other lines
-local fit_tight_class = 3 -- fitness for lines shrinking 0.5 to 1.0 of their shrinkability
-
-local new_penalty = nodepool.penalty
-local new_dir = nodepool.textdir
-local new_leftmarginkern = nodepool.leftmarginkern
-local new_rightmarginkern = nodepool.rightmarginkern
-local new_leftskip = nodepool.leftskip
-local new_rightskip = nodepool.rightskip
-local new_lineskip = nodepool.lineskip
-local new_baselineskip = nodepool.baselineskip
-local new_temp = nodepool.temp
-local new_rule = nodepool.rule
-
-local is_rotated = nodes.is_rotated
-local is_parallel = nodes.textdir_is_parallel
-local is_opposite = nodes.textdir_is_opposite
-local textdir_is_equal = nodes.textdir_is_equal
-local pardir_is_equal = nodes.pardir_is_equal
-local glyphdir_is_equal = nodes.glyphdir_is_equal
-
-local dir_pops = nodes.dir_is_pop
-local dir_negations = nodes.dir_negation
-local is_skipable = node.protrusion_skippable
-
--- helpers --
-
--- It makes more sense to move the somewhat messy dir state tracking
--- out of the main functions. First we create a stack allocator.
-
-local function new_dir_stack(dir) -- also use elsewhere
- return { n = 0, dir }
-end
-
--- The next function checks a dir node and returns the new dir state. By
--- using s static table we are quite efficient. This function is used
--- in the parbuilder.
-
-local function checked_line_dir(stack,current)
- if not dir_pops[current] then
- local n = stack.n + 1
- stack.n = n
- stack[n] = current
- return current.dir
- elseif n > 0 then
- local n = stack.n
- local dirnode = stack[n]
- dirstack.n = n - 1
- return dirnode.dir
- else
- report_parbuilders("warning: missing pop node (%a)",1) -- in line ...
- end
-end
-
--- The next function checks a dir nodes in a list and appends the negations
--- that are currently needed (some day LuaTeX will be more tolerant). We use
--- the negations for the next line.
-
-local function inject_dirs_at_end_of_line(stack,current,start,stop)
- local e = start
- local n = stack.n
- local h = nil
- while start and start ~= stop do
- if start.id == whatsit_code and start.subtype == dir_code then
- if not dir_pops[start.dir] then
- n = n + 1
- stack[n] = start
- elseif n > 0 then
- n = n - 1
- else
- report_parbuilders("warning: missing pop node (%a)",2) -- in line ...
- end
- end
- start = start.next
- end
- for i=n,1,-1 do
- h, current = insert_node_after(current,current,new_dir(dir_negations[stack[i].dir]))
- end
- stack.n = n
- return current
-end
-
-local function inject_dirs_at_begin_of_line(stack,current)
- local h = nil
- for i=stack.n,1,-1 do
- h, current = insert_node_after(current,current,new_dir(stack[i]))
- end
- stack.n = 0
- return current
-end
-
--- diagnostics --
-
-local dummy = function() end
-
-local diagnostics = {
- start = dummy,
- stop = dummy,
- current_pass = dummy,
- break_node = dummy,
- feasible_break = dummy,
-}
-
--- statistics --
-
-local nofpars, noflines, nofprotrudedlines, nofadjustedlines = 0, 0, 0, 0
-
-local function register_statistics(par)
- local statistics = par.statistics
- nofpars = nofpars + 1
- noflines = noflines + statistics.noflines
- nofprotrudedlines = nofprotrudedlines + statistics.nofprotrudedlines
- nofadjustedlines = nofadjustedlines + statistics.nofadjustedlines
-end
-
--- resolvers --
-
-local whatsiters = {
- get_width = { },
- get_dimensions = { },
-}
-
-local get_whatsit_width = whatsiters.get_width
-local get_whatsit_dimensions = whatsiters.get_dimensions
-
-local function get_width (n) return n.width end
-local function get_dimensions(n) return n.width, n.height, n.depth end
-
-get_whatsit_width[pdfrefximage_code] = get_width
-get_whatsit_width[pdfrefxform_code ] = get_width
-
-get_whatsit_dimensions[pdfrefximage_code] = get_dimensions
-get_whatsit_dimensions[pdfrefxform_code ] = get_dimensions
-
--- expansion etc --
-
-local function calculate_fraction(x,n,d,max_answer)
- local the_answer = x * n/d + 1/2 -- round ?
- if the_answer > max_answer then
- return max_answer
- elseif the_answer < -max_answer then
- return -max_answer
- else
- return the_answer
- end
-end
-
-local function check_shrinkage(par,n)
- -- called often, so maybe move inline
- if n.shrink_order ~= 0 and n.shrink ~= 0 then
- if par.no_shrink_error_yet then
- par.no_shrink_error_yet = false
- report_parbuilders("infinite glue shrinkage found in a paragraph and removed")
- end
- n = copy_node(n)
- n.shrink_order = 0
- end
- return n
-end
-
--- It doesn't really speed up much but the additional memory usage is
--- rather small so it doesn't hurt too much.
-
-local expansions = { }
-local nothing = { stretch = 0, shrink = 0 }
-
-setmetatableindex(expansions,function(t,font)
- local expansion = parameters[font].expansion -- can be an extra hash
- if expansion and expansion.auto then
- local factors = { }
- local c = chardata[font]
- setmetatableindex(factors,function(t,char)
- local fc = c[char]
- local ef = fc.expansion_factor
- if ef and ef > 0 then
- local stretch = expansion.stretch
- local shrink = expansion.shrink
- if stretch ~= 0 or shrink ~= 0 then
- local factor = ef / 1000
- local ef_quad = factor * quaddata[font] / 1000
- local v = {
- glyphstretch = stretch * ef_quad,
- glyphshrink = shrink * ef_quad,
- factor = factor,
- stretch = stretch,
- shrink = shrink ,
- }
- t[char] = v
- return v
- end
- end
- t[char] = nothing
- return nothing
- end)
- t[font] = factors
- return factors
- else
- t[font] = false
- return false
- end
-end)
-
--- local function char_stretch_shrink(p)
--- local data = expansions[p.font][p.char]
--- if data then
--- return data.glyphstretch, data.glyphshrink
--- else
--- return 0, 0
--- end
--- end
---
--- local cal_margin_kern_var = char_stretch_shrink
-
--- local function kern_stretch_shrink(p,d)
--- local l = p.prev
--- if l and l.id == glyph_code then -- how about disc nodes?
--- local r = p.next
--- if r and r.id == glyph_code then
--- local lf, rf = l.font, r.font
--- if lf == rf then
--- local data = expansions[lf][l.char]
--- if data then
--- local stretch = data.stretch
--- local shrink = data.shrink
--- if stretch ~= 0 then
--- -- stretch = data.factor * (d * stretch - d)
--- stretch = data.factor * d * (stretch - 1)
--- end
--- if shrink ~= 0 then
--- -- shrink = data.factor * (d * shrink - d)
--- shrink = data.factor * d * (shrink - 1)
--- end
--- return stretch, shrink
--- end
--- end
--- end
--- end
--- return 0, 0
--- end
-
-local function kern_stretch_shrink(p,d)
- local left = p.prev
- if left and left.id == glyph_code then -- how about disc nodes?
- local data = expansions[left.font][left.char]
- if data then
- local stretch = data.stretch
- local shrink = data.shrink
- if stretch ~= 0 then
- -- stretch = data.factor * (d * stretch - d)
- stretch = data.factor * d * (stretch - 1)
- end
- if shrink ~= 0 then
- -- shrink = data.factor * (d * shrink - d)
- shrink = data.factor * d * (shrink - 1)
- end
- return stretch, shrink
- end
- end
- return 0, 0
-end
-
-local function kern_stretch_shrink(p,d)
- return 0, 0
-end
-
--- state:
-
-local function check_expand_pars(checked_expansion,f)
- local expansion = parameters[f].expansion
- if not expansion then
- checked_expansion[f] = false
- return false
- end
- local step = expansion.step or 0
- local stretch = expansion.stretch or 0
- local shrink = expansion.shrink or 0
- if step == 0 or (stretch == 0 and schrink == 0) then
- checked_expansion[f] = false
- return false
- end
- local par = checked_expansion.par
- if par.cur_font_step < 0 then
- par.cur_font_step = step
- elseif par.cur_font_step ~= step then
- report_parbuilders("using fonts with different step of expansion in one paragraph is not allowed")
- checked_expansion[f] = false
- return false
- end
- if stretch == 0 then
- -- okay
- elseif par.max_stretch_ratio < 0 then
- par.max_stretch_ratio = stretch -- expansion_factor
- elseif par.max_stretch_ratio ~= stretch then
- report_parbuilders("using fonts with different stretch limit of expansion in one paragraph is not allowed")
- checked_expansion[f] = false
- return false
- end
- if shrink == 0 then
- -- okay
- elseif par.max_shrink_ratio < 0 then
- par.max_shrink_ratio = shrink -- - expansion_factor
- elseif par.max_shrink_ratio ~= shrink then
- report_parbuilders("using fonts with different shrink limit of expansion in one paragraph is not allowed")
- checked_expansion[f] = false
- return false
- end
- if trace_adjusting then
- report_parbuilders("expanding font %a using step %a, shrink %a and stretch %a",f,step,stretch,shrink)
- end
- local e = expansions[f]
- checked_expansion[f] = e
- return e
-end
-
-local function check_expand_lines(checked_expansion,f)
- local expansion = parameters[f].expansion
- if not expansion then
- checked_expansion[f] = false
- return false
- end
- local step = expansion.step or 0
- local stretch = expansion.stretch or 0
- local shrink = expansion.shrink or 0
- if step == 0 or (stretch == 0 and schrink == 0) then
- checked_expansion[f] = false
- return false
- end
- if trace_adjusting then
- report_parbuilders("expanding font %a using step %a, shrink %a and stretch %a",f,step,stretch,shrink)
- end
- local e = expansions[f]
- checked_expansion[f] = e
- return e
-end
-
--- protrusion
-
-local function find(head) -- do we really want to recurse into an hlist?
- while head do
- local id = head.id
- if id == glyph_code then
- return head
- elseif id == hlist_code then
- local found = find(head.list)
- if found then
- return found
- else
- head = head.next
- end
- elseif is_skipable(head) then
- head = head.next
- else
- return head
- end
- end
- return nil
-end
-
-local function find_protchar_left(l) -- weird function
- local ln = l.next
- if ln and ln.id == hlist_code and not ln.list and ln.width == 0 and ln.height == 0 and ln.depth == 0 then
- l = l.next
- else -- if d then -- was always true
- local id = l.id
- while ln and not (id == glyph_code or id < math_code) do -- is there always a glyph?
- l = ln
- ln = l.next
- id = ln.id
- end
- end
- -- if l.id == glyph_code then
- -- return l
- -- end
- return find(l) or l
-end
-
-local function find(head,tail)
- local tail = tail or slide_nodes(head)
- while tail do
- local id = tail.id
- if id == glyph_code then
- return tail
- elseif id == hlist_code then
- local found = find(tail.list)
- if found then
- return found
- else
- tail = tail.prev
- end
- elseif is_skipable(tail) then
- tail = tail.prev
- else
- return tail
- end
- end
- return nil
-end
-
-local function find_protchar_right(l,r)
- return r and find(l,r) or r
-end
-
-local function left_pw(p)
- local font = p.font
- local prot = chardata[font][p.char].left_protruding
- if not prot or prot == 0 then
- return 0
- end
- return prot * quaddata[font] / 1000, p
-end
-
-local function right_pw(p)
- local font = p.font
- local prot = chardata[font][p.char].right_protruding
- if not prot or prot == 0 then
- return 0
- end
- return prot * quaddata[font] / 1000, p
-end
-
--- par parameters
-
-local function reset_meta(par)
- local active = {
- id = hyphenated_code,
- line_number = max_halfword,
- }
- active.next = par.active -- head of metalist
- par.active = active
- par.passive = nil
-end
-
-local function add_to_width(line_break_dir,checked_expansion,s) -- split into two loops (normal and expansion)
- local size = 0
- local adjust_stretch = 0
- local adjust_shrink = 0
- while s do
- local id = s.id
- if id == glyph_code then
- if is_rotated[line_break_dir] then -- can be shared
- size = size + s.height + s.depth
- else
- size = size + s.width
- end
- if checked_expansion then
- local data = checked_expansion[s.font]
- if data then
- data = data[s.char]
- if data then
- adjust_stretch = adjust_stretch + data.glyphstretch
- adjust_shrink = adjust_shrink + data.glyphshrink
- end
- end
- end
- elseif id == hlist_code or id == vlist_code then
- if is_parallel[s.dir][line_break_dir] then
- size = size + s.width
- else
- size = size + s.depth + s.height
- end
- elseif id == kern_code then
- if checked_expansion and s.subtype == kerning_code then
- local d = s.kern
- if d ~= 0 then
- local stretch, shrink = kern_stretch_shrink(s,d)
- adjust_stretch = adjust_stretch + stretch
- adjust_shrink = adjust_shrink + shrink
- end
- end
- size = size + s.kern
- elseif id == rule_code then
- size = size + s.width
- else
- report_parbuilders("unsupported node at location %a",6)
- end
- s = s.next
- end
- return size, adjust_stretch, adjust_shrink
-end
-
-local function compute_break_width(par,break_type,p) -- split in two
- local break_width = par.break_width
- if break_type > unhyphenated_code then
- local disc_width = par.disc_width
- local checked_expansion = par.checked_expansion
- local line_break_dir = par.line_break_dir
- local break_size = break_width.size + disc_width.size
- local break_adjust_stretch = break_width.adjust_stretch + disc_width.adjust_stretch
- local break_adjust_shrink = break_width.adjust_shrink + disc_width.adjust_shrink
- local replace = p.replace
- if replace then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
- break_size = break_size - size
- break_adjust_stretch = break_adjust_stretch - adjust_stretch
- break_adjust_shrink = break_adjust_shrink - adjust_shrink
- end
- local post = p.post
- if post then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,post)
- break_size = break_size + size
- break_adjust_stretch = break_adjust_stretch + adjust_stretch
- break_adjust_shrink = break_adjust_shrink + adjust_shrink
- end
- break_width.size = break_size
- break_width.adjust_stretch = break_adjust_stretch
- break_width.adjust_shrink = break_adjust_shrink
- if not post then
- p = p.next
- else
- return
- end
- end
- while p do -- skip spacing etc
- local id = p.id
- if id == glyph_code then
- return -- happens often
- elseif id == glue_code then
- local spec = p.spec
- local order = stretch_orders[spec.stretch_order]
- break_width.size = break_width.size - spec.width
- break_width[order] = break_width[order] - spec.stretch
- break_width.shrink = break_width.shrink - spec.shrink
- elseif id == penalty_code then
- -- do nothing
- elseif id == kern_code then
- if p.subtype == userkern_code then
- break_width.size = break_width.size - p.kern
- else
- return
- end
- elseif id == math_code then
- break_width.size = break_width.size - p.surround
- else
- return
- end
- p = p.next
- end
-end
-
-local function append_to_vlist(par, b)
- local prev_depth = par.prev_depth
- if prev_depth > par.ignored_dimen then
- if b.id == hlist_code then
- local d = par.baseline_skip.width - prev_depth - b.height -- deficiency of space between baselines
- local s = d < par.line_skip_limit and new_lineskip(tex.lineskip) or new_baselineskip(d)
- -- local s = d < par.line_skip_limit
- -- if s then
- -- s = new_lineskip()
- -- s.spec = tex.lineskip
- -- else
- -- s = new_baselineskip(d)
- -- end
- local head_field = par.head_field
- if head_field then
- local n = slide_nodes(head_field)
- n.next, s.prev = s, n
- else
- par.head_field = s
- end
- end
- end
- local head_field = par.head_field
- if head_field then
- local n = slide_nodes(head_field)
- n.next, b.prev = b, n
- else
- par.head_field = b
- end
- if b.id == hlist_code then
- local pd = b.depth
- par.prev_depth = pd
- texnest[texnest.ptr].prevdepth = pd
- end
-end
-
-local function append_list(par, b)
- local head_field = par.head_field
- if head_field then
- local n = slide_nodes(head_field)
- n.next, b.prev = b, n
- else
- par.head_field = b
- end
-end
-
--- We can actually make par local to this module as we never break inside a break call and that way the
--- array is reused. At some point the information will be part of the paragraph spec as passed.
-
-local function initialize_line_break(head,display)
-
- local hang_indent = tex.hangindent or 0
- local hsize = tex.hsize or 0
- local hang_after = tex.hangafter or 0
- local par_shape_ptr = tex.parshape
- local left_skip = tex.leftskip -- nodes
- local right_skip = tex.rightskip -- nodes
- local pretolerance = tex.pretolerance
- local tolerance = tex.tolerance
- local adjust_spacing = tex.pdfadjustspacing
- local protrude_chars = tex.pdfprotrudechars
- local last_line_fit = tex.lastlinefit
-
- local newhead = new_temp()
- newhead.next = head
-
- local adjust_spacing_status = adjust_spacing > 1 and -1 or 0
-
- -- metatables
-
- local par = {
- head = newhead,
- head_field = nil,
- display = display,
- font_in_short_display = 0,
- no_shrink_error_yet = true, -- have we complained about infinite shrinkage?
- second_pass = false, -- is this our second attempt to break this paragraph?
- final_pass = false, -- is this our final attempt to break this paragraph?
- threshold = 0, -- maximum badness on feasible lines
-
- passive = nil, -- most recent node on passive list
- printed_node = head, -- most recent node that has been printed
- pass_number = 0, -- the number of passive nodes allocated on this pass
- auto_breaking = 0, -- make auto_breaking accessible out of line_break
-
- active_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
- break_width = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0, adjust_stretch = 0, adjust_shrink = 0 },
- disc_width = { size = 0, adjust_stretch = 0, adjust_shrink = 0 },
- fill_width = { stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
- background = { size = 0, stretch = 0, fi = 0, fil = 0, fill = 0, filll = 0, shrink = 0 },
-
- hang_indent = hang_indent,
- hsize = hsize,
- hang_after = hang_after,
- par_shape_ptr = par_shape_ptr,
- left_skip = left_skip,
- right_skip = right_skip,
- pretolerance = pretolerance,
- tolerance = tolerance,
-
- protrude_chars = protrude_chars,
- adjust_spacing = adjust_spacing,
- max_stretch_ratio = adjust_spacing_status,
- max_shrink_ratio = adjust_spacing_status,
- cur_font_step = adjust_spacing_status,
- checked_expansion = false,
- tracing_paragraphs = tex.tracingparagraphs > 0,
-
- emergency_stretch = tex.emergencystretch or 0,
- looseness = tex.looseness or 0,
- line_penalty = tex.linepenalty or 0,
- hyphen_penalty = tex.hyphenpenalty or 0,
- broken_penalty = tex.brokenpenalty or 0,
- inter_line_penalty = tex.interlinepenalty or 0,
- club_penalty = tex.clubpenalty or 0,
- widow_penalty = tex.widowpenalty or 0,
- display_widow_penalty = tex.displaywidowpenalty or 0,
- ex_hyphen_penalty = tex.exhyphenpenalty or 0,
-
- adj_demerits = tex.adjdemerits or 0,
- double_hyphen_demerits = tex.doublehyphendemerits or 0,
- final_hyphen_demerits = tex.finalhyphendemerits or 0,
-
- first_line = 0, -- tex.nest.modeline, -- 0, -- cur_list.pg_field
-
- each_line_height = tex.pdfeachlineheight or 0, -- this will go away
- each_line_depth = tex.pdfeachlinedepth or 0, -- this will go away
- first_line_height = tex.pdffirstlineheight or 0, -- this will go away
- last_line_depth = tex.pdflastlinedepth or 0, -- this will go away
- ignored_dimen = tex.pdfignoreddimen or 0, -- this will go away
-
- baseline_skip = tex.baselineskip or 0,
- line_skip_limit = tex.lineskiplimit or 0,
-
- prev_depth = texnest[texnest.ptr].prevdepth,
-
- final_par_glue = slide_nodes(head), -- todo: we know tail already, slow
-
- par_break_dir = tex.pardir,
- line_break_dir = tex.pardir,
-
- internal_pen_inter = 0, -- running localinterlinepenalty
- internal_pen_broken = 0, -- running localbrokenpenalty
- internal_left_box = nil, -- running localleftbox
- internal_left_box_width = 0, -- running localleftbox width
- init_internal_left_box = nil, -- running localleftbox
- init_internal_left_box_width = 0, -- running localleftbox width
- internal_right_box = nil, -- running localrightbox
- internal_right_box_width = 0, -- running localrightbox width
-
- best_place = { }, -- how to achieve minimal_demerits
- best_pl_line = { }, -- corresponding line number
- easy_line = 0, -- line numbers easy_line are equivalent in break nodes
- last_special_line = 0, -- line numbers last_special_line all have the same width
- first_width = 0, -- the width of all lines last_special_line, if no parshape has been specified
- second_width = 0, -- the width of all lines last_special_line
- first_indent = 0, -- left margin to go with first_width
- second_indent = 0, -- left margin to go with second_width
-
- best_bet = nil, -- use this passive node and its predecessors
- fewest_demerits = 0, -- the demerits associated with best_bet
- best_line = 0, -- line number following the last line of the new paragraph
- line_diff = 0, -- the difference between the current line number and the optimum best_line
-
- -- not yet used
-
- best_pl_short = { }, -- shortfall corresponding to minimal_demerits
- best_pl_glue = { }, -- corresponding glue stretch or shrink
- do_last_line_fit = false,
- last_line_fit = last_line_fit,
-
- minimum_demerits = awful_badness,
-
- minimal_demerits = {
-
- [fit_very_loose_class] = awful_badness,
- [fit_loose_class] = awful_badness,
- [fit_decent_class] = awful_badness,
- [fit_tight_class] = awful_badness,
-
- },
-
- prev_char_p = nil,
-
- font_steps = { }, -- mine
-
- statistics = {
-
- noflines = 0,
- nofprotrudedlines = 0,
- nofadjustedlines = 0,
-
- }
-
- }
-
- if adjust_spacing > 1 then
- local checked_expansion = { par = par }
- setmetatableindex(checked_expansion,check_expand_pars)
- par.checked_expansion = checked_expansion
- end
-
- -- we need par for the error message
-
- local background = par.background
-
- local l = check_shrinkage(par,left_skip)
- local r = check_shrinkage(par,right_skip)
- local l_order = stretch_orders[l.stretch_order]
- local r_order = stretch_orders[r.stretch_order]
-
- background.size = l.width + r.width
- background.shrink = l.shrink + r.shrink
- background[l_order] = l.stretch
- background[r_order] = r.stretch + background[r_order]
-
- -- this will move up so that we can assign the whole par table
-
- if not par_shape_ptr then
- if hang_indent == 0 then
- par.second_width = hsize
- par.second_indent = 0
- else
- local abs_hang_after = hang_after >0 and hang_after or -hang_after
- local abs_hang_indent = hang_indent>0 and hang_indent or -hang_indent
- par.last_special_line = abs_hang_after
- if hang_after < 0 then
- par.first_width = hsize - abs_hang_indent
- if hang_indent >= 0 then
- par.first_indent = hang_indent
- else
- par.first_indent = 0
- end
- par.second_width = hsize
- par.second_indent = 0
- else
- par.first_width = hsize
- par.first_indent = 0
- par.second_width = hsize - abs_hang_indent
- if hang_indent >= 0 then
- par.second_indent = hang_indent
- else
- par.second_indent = 0
- end
- end
- end
- else
- local last_special_line = #par_shape_ptr
- par.last_special_line = last_special_line
- local ptr = par_shape_ptr[last_special_line]
- par.second_width = ptr[2]
- par.second_indent = ptr[1]
- end
-
- if par.looseness == 0 then
- par.easy_line = par.last_special_line
- else
- par.easy_line = max_halfword
- end
-
- if pretolerance >= 0 then
- par.threshold = pretolerance
- par.second_pass = false
- par.final_pass = false
- else
- par.threshold = tolerance
- par.second_pass = true
- par.final_pass = par.emergency_stretch <= 0
- if trace_basic then
- if par.final_pass then
- report_parbuilders("enabling second and final pass")
- else
- report_parbuilders("enabling second pass")
- end
- end
- end
-
- if last_line_fit > 0 then
- local spec = par.final_par_glue.spec
- local stretch = spec.stretch
- local stretch_order = spec.stretch_order
- if stretch > 0 and stretch_order > 0 and background.fi == 0 and background.fil == 0 and background.fill == 0 and background.filll == 0 then
- par.do_last_line_fit = true
- local si = stretch_orders[stretch_order]
- if trace_lastlinefit or trace_basic then
- report_parbuilders("enabling last line fit, stretch order %a set to %a, linefit is %a",si,stretch,last_line_fit)
- end
- par.fill_width[si] = stretch
- end
- end
-
- return par
-end
-
-local function post_line_break(par)
-
- local prevgraf = texnest[texnest.ptr].prevgraf
- local cur_line = prevgraf + 1 -- the current line number being justified
- local cur_p = nil
-
- local adjust_spacing = par.adjust_spacing
- local protrude_chars = par.protrude_chars
- local statistics = par.statistics
-
- local p, s, k, w -- check when local
-
- local q = par.best_bet.break_node
- repeat -- goto first breakpoint
- local r = q
- q = q.prev_break
- r.prev_break = cur_p
- cur_p = r
- until not q
-
- local stack = new_dir_stack()
-
- repeat
-
- inject_dirs_at_begin_of_line(stack,par.head)
-
- local q = nil
- local r = cur_p.cur_break
-
- local disc_break = false
- local post_disc_break = false
- local glue_break = false
-
- if not r then
- r = slide_nodes(par.head)
- if r == par.final_par_glue then
- q = r -- q refers to the last node of the line (and paragraph)
- r = r.prev -- r refers to the node after which the dir nodes should be closed
- end
- else
- local id = r.id
- if id == glue_code then
- -- r is normal skip
- r = replace_node(r,new_rightskip(par.right_skip))
- glue_break = true
- q = r -- q refers to the last node of the line
- r = r.prev -- r refers to the node after which the dir nodes should be closed
- elseif id == disc_code then
- -- todo: use insert_before/after
- local prev_r = r.prev
- local next_r = r.next
- local subtype = r.subtype
- local pre = r.pre
- local post = r.post
- local replace = r.replace
- if subtype == second_disc_code then
- if not (prev_r.id == disc_code and prev_r.subtype == first_disc_code) then
- report_parbuilders('unsupported disc at location %a',3)
- end
- if pre then
- flush_node_list(pre)
- r.pre = nil
- pre = nil -- signal
- end
- if replace then
- local n = slide_nodes(replace)
- prev_r.next = replace
- replace.prev = prev_r
- n.next = r
- r.prev = n
- r.replace = nil
- replace = nil -- signal
- end
- local pre = prev_r.pre
- local post = prev_r.post
- local replace = prev_r.replace
- if pre then
- flush_node_list(pre)
- prev_r.pre = nil
- end
- if replace then
- flush_node_list(replace)
- prev_r.replace = nil
- end
- if post then
- flush_node_list(post)
- prev_r.post = nil
- end
- elseif subtype == first_disc_code then
- if not (v.id == disc_code and v.subtype == second_disc_code) then
- report_parbuilders('unsupported disc at location %a',4)
- end
- next_r.subtype = regular_disc_code
- next_r.replace = post
- r.post = nil
- end
- if replace then
- r.replace = nil -- free
- flush_node_list(replace)
- end
- if pre then
- local n = slide_nodes(pre)
- prev_r.next = pre
- pre.prev = prev_r
- n.next = r
- r.prev = n
- r.pre = nil
- end
- if post then
- local n = slide_nodes(post)
- r.next = post
- post.prev = r
- n.next = next_r
- next_r.prev = n
- r.post = nil
- post_disc_break = true
- end
- disc_break = true
- elseif id == kern_code then
- r.kern = 0
- elseif r.id == math_code then
- r.surround = 0
- end
- end
- r = inject_dirs_at_end_of_line(stack,r,par.head.next,cur_p.cur_break)
- local crb = cur_p.passive_right_box
- if crb then
- local s = copy_node(crb)
- local e = r.next
- r.next = s
- s.prev = r
- s.next = e
- if e then
- e.prev = s
- end
- r = s
- end
- if not q then
- q = r
- end
- if q and q ~= par.head and protrude_chars > 0 then
- local id = q.id
- local c = (disc_break and (id == glyph_code or id ~= disc_code) and q) or q.prev
- local p = find_protchar_right(par.head.next,c)
- if p and p.id == glyph_code then
- local w, last_rightmost_char = right_pw(p)
- if last_rightmost_char and w ~= 0 then
- -- so we inherit attributes, q is new pseudo head
- q, c = insert_node_after(q,c,new_rightmarginkern(copy_node(last_rightmost_char),-w))
- end
- end
- end
- if not glue_break then
- local h
- h, q = insert_node_after(q,q,new_rightskip(par.right_skip)) -- q moves on as pseudo head
- end
- r = q.next
- q.next = nil
- local phead = par.head
- q = phead.next
- phead.next = r
- if r then
- r.prev = phead
- end
- local clb = cur_p.passive_left_box
- if clb then -- here we miss some prev links
- local s = copy_node(cb)
- s = q.next
- r.next = q
- q = r
- if s and cur_line == (par.first_line + 1) and s.id == hlist_code and not s.list then
- q = q.next
- r.next = s.next
- s.next = r
- end
- end
- if protrude_chars > 0 then
- local p = find_protchar_left(q)
- if p and p.id == glyph_code then
- local w, last_leftmost_char = left_pw(p)
- if last_leftmost_char and w ~= 0 then
- -- so we inherit attributes, q is pseudo head and moves back
- q = insert_node_before(q,q,new_leftmarginkern(copy_node(last_leftmost_char),-w))
- end
- end
- end
- local ls = par.left_skip
- if ls and (ls.width ~= 0 or ls.stretch ~= 0 or ls.shrink ~= 0) then
- q = insert_node_before(q,q,new_leftskip(ls))
- end
- local curwidth, cur_indent
- if cur_line > par.last_special_line then
- cur_indent = par.second_indent
- cur_width = par.second_width
- else
- local psp = par.par_shape_ptr
- if psp then
- cur_indent = psp[cur_line][1]
- cur_width = psp[cur_line][2]
- else
- cur_indent = par.first_indent
- cur_width = par.first_width
- end
- end
- statistics.noflines = statistics.noflines + 1
- if adjust_spacing > 0 then
- statistics.nofadjustedlines = statistics.nofadjustedlines + 1
- just_box = xpack_nodes(q,cur_width,"cal_expand_ratio",par.par_break_dir) -- ,cur_p.analysis)
- else
- just_box = xpack_nodes(q,cur_width,"exactly",par.par_break_dir) -- ,cur_p.analysis)
- end
- if protrude_chars > 0 then
- statistics.nofprotrudedlines = statistics.nofprotrudedlines + 1
- end
- -- wrong:
- local adjust_head = texlists.adjust_head
- local pre_adjust_head = texlists.pre_adjust_head
- --
- just_box.shift = cur_indent
- if par.each_line_height ~= par.ignored_dimen then
- just_box.height = par.each_line_height
- end
- if par.each_line_depth ~= par.ignored_dimen then
- just_box.depth = par.each_line_depth
- end
- if par.first_line_height ~= par.ignored_dimen and (cur_line == par.first_line + 1) then
- just_box.height = par.first_line_height
- end
- if par.last_line_depth ~= par.ignored_dimen and cur_line + 1 == par.best_line then
- just_box.depth = par.last_line_depth
- end
- if texlists.pre_adjust_head ~= pre_adjust_head then
- append_list(par, texlists.pre_adjust_head)
- texlists.pre_adjust_head = pre_adjust_head
- end
- append_to_vlist(par, just_box)
- if texlists.adjust_head ~= adjust_head then
- append_list(par, texlists.adjust_head)
- texlists.adjust_head = adjust_head
- end
- local pen
- if cur_line + 1 ~= par.best_line then
- if cur_p.passive_pen_inter then
- pen = cur_p.passive_pen_inter
- else
- pen = par.inter_line_penalty
- end
- if cur_line == prevgraf + 1 then
- pen = pen + par.club_penalty
- end
- if cur_line + 2 == par.best_line then
- if par.display then
- pen = pen + par.display_widow_penalty
- else
- pen = pen + par.widow_penalty
- end
- end
- if disc_break then
- if cur_p.passive_pen_broken ~= 0 then
- pen = pen + cur_p.passive_pen_broken
- else
- pen = pen + par.broken_penalty
- end
- end
- if pen ~= 0 then
- append_to_vlist(par,new_penalty(pen))
- end
- end
- cur_line = cur_line + 1
- cur_p = cur_p.prev_break
- if cur_p and not post_disc_break then
- local phead = par.head
- local r = phead
- while true do
- q = r.next
- if q == cur_p.cur_break or q.id == glyph_code then
- break
- end
- local id = q.id
- if not (id == whatsit_code and q.subtype == localpar_code) then
- if id < math_code or (id == kern_code and q.subtype ~= userkern_code) then
- break
- end
- end
- r = q
- end
- if r ~= phead then
- r.next = nil
- flush_node_list(phead.next)
- phead.next = q
- if q then
- q.prev = phead
- end
- end
- end
- until not cur_p
- if cur_line ~= par.best_line then -- or not par.head.next then
- report_parbuilders("line breaking")
- end
- if par.head then -- added
--- flush_node(par.head) -- the localpar_code whatsit
- par.head = nil
- end
- cur_line = cur_line - 1
- if trace_basic then
- report_parbuilders("paragraph broken into %a lines",cur_line)
- end
- texnest[texnest.ptr].prevgraf = cur_line
-end
-
-local function wrap_up(par)
- if par.tracing_paragraphs then
- diagnostics.stop()
- end
- if par.do_last_line_fit then
- local best_bet = par.best_bet
- local active_short = best_bet.active_short
- local active_glue = best_bet.active_glue
- if active_short == 0 then
- if trace_lastlinefit then
- report_parbuilders("disabling last line fit, no active_short")
- end
- par.do_last_line_fit = false
- else
- local glue = par.final_par_glue
- local spec = copy_node(glue.spec)
- spec.width = spec.width + active_short - active_glue
- spec.stretch = 0
- -- flush_node(glue.spec) -- brrr, when we do this we can get an "invalid id stretch message", maybe dec refcount
- glue.spec = spec
- if trace_lastlinefit then
- report_parbuilders("applying last line fit, short %a, glue %p",active_short,active_glue)
- end
- end
- end
- -- we have a bunch of glue and and temp nodes not freed
- local head = par.head
- if head.id == temp_code then
- par.head = head.next
- flush_node(head)
- end
- post_line_break(par)
- reset_meta(par)
- register_statistics(par)
- return par.head_field
-end
-
--- we could do active nodes differently ... table instead of linked list or a list
--- with prev nodes
-
-local function deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion) -- no need for adjust if disabled
- local active = par.active
- local active_width = par.active_width
- prev_r.next = r.next
- -- removes r
- -- r = nil
- if prev_r == active then
- r = active.next
- if r.id == delta_code then
- local aw = active_width.size + r.size active_width.size = aw cur_active_width.size = aw
- local aw = active_width.stretch + r.stretch active_width.stretch = aw cur_active_width.stretch = aw
- local aw = active_width.fi + r.fi active_width.fi = aw cur_active_width.fi = aw
- local aw = active_width.fil + r.fil active_width.fil = aw cur_active_width.fil = aw
- local aw = active_width.fill + r.fill active_width.fill = aw cur_active_width.fill = aw
- local aw = active_width.filll + r.filll active_width.filll = aw cur_active_width.filll = aw
- local aw = active_width.shrink + r.shrink active_width.shrink = aw cur_active_width.shrink = aw
- if checked_expansion then
- local aw = active_width.adjust_stretch + r.adjust_stretch active_width.adjust_stretch = aw cur_active_width.adjust_stretch = aw
- local aw = active_width.adjust_shrink + r.adjust_shrink active_width.adjust_shrink = aw cur_active_width.adjust_shrink = aw
- end
- active.next = r.next
- -- removes r
- -- r = nil
- end
- elseif prev_r.id == delta_code then
- r = prev_r.next
- if r == active then
- cur_active_width.size = cur_active_width.size - prev_r.size
- cur_active_width.stretch = cur_active_width.stretch - prev_r.stretch
- cur_active_width.fi = cur_active_width.fi - prev_r.fi
- cur_active_width.fil = cur_active_width.fil - prev_r.fil
- cur_active_width.fill = cur_active_width.fill - prev_r.fill
- cur_active_width.filll = cur_active_width.filll - prev_r.filll
- cur_active_width.shrink = cur_active_width.shrink - prev_r.shrink
- if checked_expansion then
- cur_active_width.adjust_stretch = cur_active_width.adjust_stretch - prev_r.adjust_stretch
- cur_active_width.adjust_shrink = cur_active_width.adjust_shrink - prev_r.adjust_shrink
- end
- prev_prev_r.next = active
- -- removes prev_r
- -- prev_r = nil
- prev_r = prev_prev_r
- elseif r.id == delta_code then
- local rn = r.size cur_active_width.size = cur_active_width.size + rn prev_r.size = prev_r.size + rn
- local rn = r.stretch cur_active_width.stretch = cur_active_width.stretch + rn prev_r.stretch = prev_r.stretch + rn
- local rn = r.fi cur_active_width.fi = cur_active_width.fi + rn prev_r.fi = prev_r.fi + rn
- local rn = r.fil cur_active_width.fil = cur_active_width.fil + rn prev_r.fil = prev_r.fil + rn
- local rn = r.fill cur_active_width.fill = cur_active_width.fill + rn prev_r.fill = prev_r.fill + rn
- local rn = r.filll cur_active_width.filll = cur_active_width.filll + rn prev_r.filll = prev_r.fill + rn
- local rn = r.shrink cur_active_width.shrink = cur_active_width.shrink + rn prev_r.shrink = prev_r.shrink + rn
- if checked_expansion then
- local rn = r.adjust_stretch cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + rn prev_r.adjust_stretch = prev_r.adjust_stretch + rn
- local rn = r.adjust_shrink cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + rn prev_r.adjust_shrink = prev_r.adjust_shrink + rn
- end
- prev_r.next = r.next
- -- removes r
- -- r = nil
- end
- end
- return prev_r, r
-end
-
-local function lastlinecrap(shortfall,active_short,active_glue,cur_active_width,fill_width,last_line_fit)
- if active_short == 0 or active_glue <= 0 then
- return false, 0, fit_decent_class, 0, 0
- end
- if cur_active_width.fi ~= fill_width.fi or cur_active_width.fil ~= fill_width.fil or cur_active_width.fill ~= fill_width.fill or cur_active_width.filll ~= fill_width.filll then
- return false, 0, fit_decent_class, 0, 0
- end
- local adjustment = active_short > 0 and cur_active_width.stretch or cur_active_width.shrink
- if adjustment <= 0 then
- return false, 0, fit_decent_class, adjustment, 0
- end
- adjustment = calculate_fraction(adjustment,active_short,active_glue,maxdimen)
- if last_line_fit < 1000 then
- adjustment = calculate_fraction(adjustment,last_line_fit,1000,maxdimen) -- uses previous adjustment
- end
- local fit_class = fit_decent_class
- if adjustment > 0 then
- local stretch = cur_active_width.stretch
- if adjustment > shortfall then
- adjustment = shortfall
- end
- if adjustment > 7230584 and stretch < 1663497 then
- return true, fit_very_loose_class, shortfall, adjustment, infinite_badness
- end
- -- if adjustment == 0 then -- badness = 0
- -- return true, shortfall, fit_decent_class, 0, 0
- -- elseif stretch <= 0 then -- badness = 10000
- -- return true, shortfall, fit_very_loose_class, adjustment, 10000
- -- end
- -- local badness = (adjustment == 0 and 0) or (stretch <= 0 and 10000) or calculate_badness(adjustment,stretch)
- local badness = calculate_badness(adjustment,stretch)
- if badness > 99 then
- return true, shortfall, fit_very_loose_class, adjustment, badness
- elseif badness > 12 then
- return true, shortfall, fit_loose_class, adjustment, badness
- else
- return true, shortfall, fit_decent_class, adjustment, badness
- end
- elseif adjustment < 0 then
- local shrink = cur_active_width.shrink
- if -adjustment > shrink then
- adjustment = -shrink
- end
- local badness = calculate_badness(-adjustment,shrink)
- if badness > 12 then
- return true, shortfall, fit_tight_class, adjustment, badness
- else
- return true, shortfall, fit_decent_class, adjustment, badness
- end
- else
- return false, 0, fit_decent_class, 0, 0
- end
-end
-
-local function try_break(pi, break_type, par, first_p, cur_p, checked_expansion)
-
- if pi >= infinite_penalty then
- return -- this breakpoint is inhibited by infinite penalty
- elseif pi <= -infinite_penalty then
- pi = eject_penalty -- this breakpoint will be forced
- end
-
- local prev_prev_r = nil -- a step behind prev_r, if type(prev_r)=delta_code
- local prev_r = par.active -- stays a step behind r
- local r = nil -- runs through the active list
- local no_break_yet = true -- have we found a feasible break at cur_p?
- local node_r_stays_active = false -- should node r remain in the active list?
- local line_width = 0 -- the current line will be justified to this width
- local line_number = 0 -- line number of current active node
- local old_line_number = 0 -- maximum line number in current equivalence class of lines
-
- local protrude_chars = par.protrude_chars
- local checked_expansion = par.checked_expansion
- local break_width = par.break_width
- local active_width = par.active_width
- local background = par.background
- local minimal_demerits = par.minimal_demerits
- local best_place = par.best_place
- local best_pl_line = par.best_pl_line
- local best_pl_short = par.best_pl_short
- local best_pl_glue = par.best_pl_glue
- local do_last_line_fit = par.do_last_line_fit
- local final_pass = par.final_pass
- local tracing_paragraphs = par.tracing_paragraphs
- -- local par_active = par.active
-
- local cur_active_width = checked_expansion and { -- distance from current active node
- size = active_width.size,
- stretch = active_width.stretch,
- fi = active_width.fi,
- fil = active_width.fil,
- fill = active_width.fill,
- filll = active_width.filll,
- shrink = active_width.shrink,
- adjust_stretch = active_width.adjust_stretch,
- adjust_shrink = active_width.adjust_shrink,
- } or {
- size = active_width.size,
- stretch = active_width.stretch,
- fi = active_width.fi,
- fil = active_width.fil,
- fill = active_width.fill,
- filll = active_width.filll,
- shrink = active_width.shrink,
- }
-
- while true do
- r = prev_r.next
- if r.id == delta_code then
- cur_active_width.size = cur_active_width.size + r.size
- cur_active_width.stretch = cur_active_width.stretch + r.stretch
- cur_active_width.fi = cur_active_width.fi + r.fi
- cur_active_width.fil = cur_active_width.fil + r.fil
- cur_active_width.fill = cur_active_width.fill + r.fill
- cur_active_width.filll = cur_active_width.filll + r.filll
- cur_active_width.shrink = cur_active_width.shrink + r.shrink
- if checked_expansion then
- cur_active_width.adjust_stretch = cur_active_width.adjust_stretch + r.adjust_stretch
- cur_active_width.adjust_shrink = cur_active_width.adjust_shrink + r.adjust_shrink
- end
- prev_prev_r = prev_r
- prev_r = r
- else
- line_number = r.line_number
- if line_number > old_line_number then
- local minimum_demerits = par.minimum_demerits
- if minimum_demerits < awful_badness and (old_line_number ~= par.easy_line or r == par.active) then
- if no_break_yet then
- no_break_yet = false
- break_width.size = background.size
- break_width.stretch = background.stretch
- break_width.fi = background.fi
- break_width.fil = background.fil
- break_width.fill = background.fill
- break_width.filll = background.filll
- break_width.shrink = background.shrink
- if checked_expansion then
- break_width.adjust_stretch = 0
- break_width.adjust_shrink = 0
- end
- if cur_p then
- compute_break_width(par,break_type,cur_p)
- end
- end
- if prev_r.id == delta_code then
- prev_r.size = prev_r.size - cur_active_width.size + break_width.size
- prev_r.stretch = prev_r.stretch - cur_active_width.stretc + break_width.stretch
- prev_r.fi = prev_r.fi - cur_active_width.fi + break_width.fi
- prev_r.fil = prev_r.fil - cur_active_width.fil + break_width.fil
- prev_r.fill = prev_r.fill - cur_active_width.fill + break_width.fill
- prev_r.filll = prev_r.filll - cur_active_width.filll + break_width.filll
- prev_r.shrink = prev_r.shrink - cur_active_width.shrink + break_width.shrink
- if checked_expansion then
- prev_r.adjust_stretch = prev_r.adjust_stretch - cur_active_width.adjust_stretch + break_width.adjust_stretch
- prev_r.adjust_shrink = prev_r.adjust_shrink - cur_active_width.adjust_shrink + break_width.adjust_shrink
- end
- elseif prev_r == par.active then
- active_width.size = break_width.size
- active_width.stretch = break_width.stretch
- active_width.fi = break_width.fi
- active_width.fil = break_width.fil
- active_width.fill = break_width.fill
- active_width.filll = break_width.filll
- active_width.shrink = break_width.shrink
- if checked_expansion then
- active_width.adjust_stretch = break_width.adjust_stretch
- active_width.adjust_shrink = break_width.adjust_shrink
- end
- else
- local q = checked_expansion and {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = break_width.size - cur_active_width.size,
- stretch = break_width.stretch - cur_active_width.stretch,
- fi = break_width.fi - cur_active_width.fi,
- fil = break_width.fil - cur_active_width.fil,
- fill = break_width.fill - cur_active_width.fill,
- filll = break_width.filll - cur_active_width.filll,
- shrink = break_width.shrink - cur_active_width.shrink,
- adjust_stretch = break_width.adjust_stretch - cur_active_width.adjust_stretch,
- adjust_shrink = break_width.adjust_shrink - cur_active_width.adjust_shrink,
- } or {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = break_width.size - cur_active_width.size,
- stretch = break_width.stretch - cur_active_width.stretch,
- fi = break_width.fi - cur_active_width.fi,
- fil = break_width.fil - cur_active_width.fil,
- fill = break_width.fill - cur_active_width.fill,
- filll = break_width.filll - cur_active_width.filll,
- shrink = break_width.shrink - cur_active_width.shrink,
- }
- prev_r.next = q
- prev_prev_r = prev_r
- prev_r = q
- end
- local adj_demerits = par.adj_demerits
- local abs_adj_demerits = adj_demerits > 0 and adj_demerits or -adj_demerits
- if abs_adj_demerits >= awful_badness - minimum_demerits then
- minimum_demerits = awful_badness - 1
- else
- minimum_demerits = minimum_demerits + abs_adj_demerits
- end
- for fit_class = fit_very_loose_class, fit_tight_class do
- if minimal_demerits[fit_class] <= minimum_demerits then
- -- insert a new active node from best_place[fit_class] to cur_p
- par.pass_number = par.pass_number + 1
- local prev_break = best_place[fit_class]
- local passive = {
- id = passive_code,
- subtype = nosubtype_code,
- next = par.passive,
- cur_break = cur_p,
- serial = par.pass_number,
- prev_break = prev_break,
- passive_pen_inter = par.internal_pen_inter,
- passive_pen_broken = par.internal_pen_broken,
- passive_last_left_box = par.internal_left_box,
- passive_last_left_box_width = par.internal_left_box_width,
- passive_left_box = prev_break and prev_break.passive_last_left_box or par.init_internal_left_box,
- passive_left_box_width = prev_break and prev_break.passive_last_left_box_width or par.init_internal_left_box_width,
- passive_right_box = par.internal_right_box,
- passive_right_box_width = par.internal_right_box_width,
--- analysis = table.fastcopy(cur_active_width),
- }
- par.passive = passive
- local q = {
- id = break_type,
- subtype = fit_class,
- break_node = passive,
- line_number = best_pl_line[fit_class] + 1,
- total_demerits = minimal_demerits[fit_class], -- or 0,
- next = r,
- }
- if do_last_line_fit then
- local active_short = best_pl_short[fit_class]
- local active_glue = best_pl_glue[fit_class]
- q.active_short = active_short
- q.active_glue = active_glue
- if trace_lastlinefit then
- report_parbuilders("setting short to %i and glue to %p using class %a",active_short,active_glue,fit_class)
- end
- end
- -- q.next = r -- already done
- prev_r.next = q
- prev_r = q
- if tracing_paragraphs then
- diagnostics.break_node(par,q,fit_class,break_type,cur_p)
- end
- end
- minimal_demerits[fit_class] = awful_badness
- end
- par.minimum_demerits = awful_badness
- if r ~= par.active then
- local q = checked_expansion and {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = cur_active_width.size - break_width.size,
- stretch = cur_active_width.stretch - break_width.stretch,
- fi = cur_active_width.fi - break_width.fi,
- fil = cur_active_width.fil - break_width.fil,
- fill = cur_active_width.fill - break_width.fill,
- filll = cur_active_width.filll - break_width.filll,
- shrink = cur_active_width.shrink - break_width.shrink,
- adjust_stretch = cur_active_width.adjust_stretch - break_width.adjust_stretch,
- adjust_shrink = cur_active_width.adjust_shrink - break_width.adjust_shrink,
- } or {
- id = delta_code,
- subtype = nosubtype_code,
- next = r,
- size = cur_active_width.size - break_width.size,
- stretch = cur_active_width.stretch - break_width.stretch,
- fi = cur_active_width.fi - break_width.fi,
- fil = cur_active_width.fil - break_width.fil,
- fill = cur_active_width.fill - break_width.fill,
- filll = cur_active_width.filll - break_width.filll,
- shrink = cur_active_width.shrink - break_width.shrink,
- }
- -- q.next = r -- already done
- prev_r.next = q
- prev_prev_r = prev_r
- prev_r = q
- end
- end
- if r == par.active then
- return
- end
- if line_number > par.easy_line then
- old_line_number = max_halfword - 1
- line_width = par.second_width
- else
- old_line_number = line_number
- if line_number > par.last_special_line then
- line_width = par.second_width
- elseif par.par_shape_ptr then
- line_width = par.par_shape_ptr[line_number][2]
- else
- line_width = par.first_width
- end
- end
- end
- local artificial_demerits = false -- has d been forced to zero
- local shortfall = line_width - cur_active_width.size - par.internal_right_box_width -- used in badness calculations
- if not r.break_node then
- shortfall = shortfall - par.init_internal_left_box_width
- else
- shortfall = shortfall - (r.break_node.passive_last_left_box_width or 0)
- end
- local pw, lp, rp -- used later on
- if protrude_chars > 1 then
- -- this is quite time consuming
- local b = r.break_node
- local l = b and b.cur_break or first_p
- local o = cur_p and cur_p.prev
- if cur_p and cur_p.id == disc_code and cur_p.pre then
- o = slide_nodes(cur_p.pre)
- else
- o = find_protchar_right(l,o)
- end
- if o and o.id == glyph_code then
- pw, rp = right_pw(o)
- shortfall = shortfall + pw
- end
- local id = l.id
- if id == glyph_code then
- -- ok ?
- elseif id == disc_code and l.post then
- l = l.post -- TODO: first char could be a disc
- else
- l = find_protchar_left(l)
- end
- if l and l.id == glyph_code then
- pw, lp = left_pw(l)
- shortfall = shortfall + pw
- end
- end
- if checked_expansion and shortfall ~= 0 then
- local margin_kern_stretch = 0
- local margin_kern_shrink = 0
- if protrude_chars > 1 then
- if lp then
--- margin_kern_stretch, margin_kern_shrink = cal_margin_kern_var(lp)
-local data = expansions[lp.font][lp.char]
-if data then
- margin_kern_stretch, margin_kern_shrink = data.glyphstretch, data.glyphshrink
-end
- end
- if rp then
--- local mka, mkb = cal_margin_kern_var(rp)
--- margin_kern_stretch = margin_kern_stretch + mka
--- margin_kern_shrink = margin_kern_shrink + mkb
-local data = expansions[lp.font][lp.char]
-if data then
- margin_kern_stretch = margin_kern_stretch + data.glyphstretch
- margin_kern_shrink = margin_kern_shrink + data.glyphshrink
-end
- end
- end
- local total = cur_active_width.adjust_stretch + margin_kern_stretch
- if shortfall > 0 and total > 0 then
- if total > shortfall then
- shortfall = total / (par.max_stretch_ratio / par.cur_font_step) / 2
- else
- shortfall = shortfall - total
- end
- else
- total = cur_active_width.adjust_shrink + margin_kern_shrink
- if shortfall < 0 and total > 0 then
- if total > - shortfall then
- shortfall = - total / (par.max_shrink_ratio / par.cur_font_step) / 2
- else
- shortfall = shortfall + total
- end
- end
- end
- par.font_steps[line_number] = par.cur_font_step -- mine
- else
- par.font_steps[line_number] = 0 -- mine
- end
- local b = 0
- local g = 0
- local fit_class = fit_decent_class
- local found = false
- if shortfall > 0 then
- if cur_active_width.fi ~= 0 or cur_active_width.fil ~= 0 or cur_active_width.fill ~= 0 or cur_active_width.filll ~= 0 then
- if not do_last_line_fit then
- -- okay
- elseif not cur_p then
- found, shortfall, fit_class, g, b = lastlinecrap(shortfall,r.active_short,r.active_glue,cur_active_width,par.fill_width,par.last_line_fit)
- else
- shortfall = 0
- end
- else
- local stretch = cur_active_width.stretch
- if shortfall > 7230584 and stretch < 1663497 then
- b = infinite_badness
- fit_class = fit_very_loose_class
- else
- b = calculate_badness(shortfall,stretch)
- if b > 99 then
- fit_class = fit_very_loose_class
- elseif b > 12 then
- fit_class = fit_loose_class
- else
- fit_class = fit_decent_class
- end
- end
- end
- else
- local shrink = cur_active_width.shrink
- if -shortfall > shrink then
- b = infinite_badness + 1
- else
- b = calculate_badness(-shortfall,shrink)
- end
- if b > 12 then
- fit_class = fit_tight_class
- else
- fit_class = fit_decent_class
- end
- end
- if do_last_line_fit and not found then
- if not cur_p then
- -- g = 0
- shortfall = 0
- elseif shortfall > 0 then
- g = cur_active_width.stretch
- elseif shortfall < 0 then
- g = cur_active_width.shrink
- else
- g = 0
- end
- end
- -- ::FOUND::
- local continue_only = false -- brrr
- if b > infinite_badness or pi == eject_penalty then
- if final_pass and par.minimum_demerits == awful_badness and r.next == par.active and prev_r == par.active then
- artificial_demerits = true -- set demerits zero, this break is forced
- node_r_stays_active = false
- elseif b > par.threshold then
- prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
- continue_only = true
- else
- node_r_stays_active = false
- end
- else
- prev_r = r
- if b > par.threshold then
- continue_only = true
- else
- node_r_stays_active = true
- end
- end
- if not continue_only then
- local d = 0
- if not artificial_demerits then
- d = par.line_penalty + b
- if (d >= 0 and d or -d) >= 10000 then -- abs(d)
- d = 100000000
- else
- d = d * d
- end
- if pi == 0 then
- -- nothing
- elseif pi > 0 then
- d = d + pi * pi
- elseif pi > eject_penalty then
- d = d - pi * pi
- end
- if break_type == hyphenated_code and r.id == hyphenated_code then
- if cur_p then
- d = d + par.double_hyphen_demerits
- else
- d = d + par.final_hyphen_demerits
- end
- end
- local delta = fit_class - r.subtype
- if (delta >= 0 and delta or -delta) > 1 then -- abs(delta)
- d = d + par.adj_demerits
- end
- end
- if tracing_paragraphs then
- diagnostics.feasible_break(par,cur_p,r,b,pi,d,artificial_demerits)
- end
- d = d + r.total_demerits -- this is the minimum total demerits from the beginning to cur_p via r
- if d <= minimal_demerits[fit_class] then
- minimal_demerits[fit_class] = d
- best_place [fit_class] = r.break_node
- best_pl_line [fit_class] = line_number
- if do_last_line_fit then
- best_pl_short[fit_class] = shortfall
- best_pl_glue [fit_class] = g
- if trace_lastlinefit then
- report_parbuilders("storing last line fit short %a and glue %p in class %a",shortfall,g,fit_class)
- end
- end
- if d < par.minimum_demerits then
- par.minimum_demerits = d
- end
- end
- if not node_r_stays_active then
- prev_r, r = deactivate_node(par,prev_prev_r,prev_r,r,cur_active_width,checked_expansion)
- end
- end
- end
- end
-end
-
-local function kern_break(par, cur_p, first_p, checked_expansion) -- move inline if needed
- local v = cur_p.next
- if par.auto_breaking and v.id == glue_code then
- try_break(0, unhyphenated_code, par, first_p, cur_p, checked_expansion)
- end
- local active_width = par.active_width
- if cur_p.id ~= math_code then
- active_width.size = active_width.size + cur_p.kern
- else
- active_width.size = active_width.size + cur_p.surround
- end
-end
-
--- we can call the normal one for simple box building in the otr so we need
--- frequent enabling/disabling
-
-local temp_head = new_temp()
-
-function constructors.methods.basic(head,d)
- if trace_basic then
- report_parbuilders("starting at %a",head)
- end
-
- local par = initialize_line_break(head,d)
-
- local checked_expansion = par.checked_expansion
- local active_width = par.active_width
- local disc_width = par.disc_width
- local background = par.background
- local tracing_paragraphs = par.tracing_paragraphs
-
- local dirstack = new_dir_stack()
-
- if tracing_paragraphs then
- diagnostics.start()
- if par.pretolerance >= 0 then
- diagnostics.current_pass(par,"firstpass")
- end
- end
-
- while true do
- reset_meta(par)
- if par.threshold > infinite_badness then
- par.threshold = infinite_badness
- end
- par.active.next = {
- id = unhyphenated_code,
- subtype = fit_decent_class,
- next = par.active,
- break_node = nil,
- line_number = par.first_line + 1,
- total_demerits = 0,
- active_short = 0,
- active_glue = 0,
- }
- active_width.size = background.size
- active_width.stretch = background.stretch
- active_width.fi = background.fi
- active_width.fil = background.fil
- active_width.fill = background.fill
- active_width.filll = background.filll
- active_width.shrink = background.shrink
-
- if checked_expansion then
- active_width.adjust_stretch = 0
- active_width.adjust_shrink = 0
- end
-
- par.passive = nil -- = 0
- par.printed_node = temp_head -- only when tracing, shared
- par.printed_node.next = head
- par.pass_number = 0
- par.auto_breaking = true
-
- local cur_p = head
- local first_p = cur_p
-
- par.font_in_short_display = 0
-
- if cur_p and cur_p.id == whatsit_code and cur_p.subtype == localpar_code then
- par.init_internal_left_box = cur_p.box_left
- par.init_internal_left_box_width = cur_p.box_left_width
- par.internal_pen_inter = cur_p.pen_inter
- par.internal_pen_broken = cur_p.pen_broken
- par.internal_left_box = par.init_internal_left_box
- par.internal_left_box_width = par.init_internal_left_box_width
- par.internal_right_box = cur_p.box_right
- par.internal_right_box_width = cur_p.box_right_width
- end
-
- -- all passes are combined in this loop so maybe we should split this into
- -- three function calls; we then also need to do the wrap_up elsewhere
-
- -- split into normal and expansion loop
-
- -- use an active local
-
- local fontexp, lastfont -- we can pass fontexp to calculate width if needed
-
- while cur_p and par.active.next ~= par.active do
- while cur_p and cur_p.id == glyph_code do
- if is_rotated[par.line_break_dir] then
- active_width.size = active_width.size + cur_p.height + cur_p.depth
- else
- active_width.size = active_width.size + cur_p.width
- end
- if checked_expansion then
- local data= checked_expansion[cur_p.font]
- if data then
- local currentfont = cur_p.font
- if currentfont ~= lastfont then
- fontexps = checked_expansion[currentfont] -- a bit redundant for the par line packer
- lastfont = currentfont
- end
- if fontexps then
- local expansion = fontexps[cur_p.char]
- if expansion then
- active_width.adjust_stretch = active_width.adjust_stretch + expansion.glyphstretch
- active_width.adjust_shrink = active_width.adjust_shrink + expansion.glyphshrink
- end
- end
- end
- end
- cur_p = cur_p.next
- end
- if not cur_p then -- TODO
- report_parbuilders("problems with linebreak_tail")
- os.exit()
- end
- local id = cur_p.id
- if id == hlist_code or id == vlist_code then
- if is_parallel[cur_p.dir][par.line_break_dir] then
- active_width.size = active_width.size + cur_p.width
- else
- active_width.size = active_width.size + cur_p.depth + cur_p.height
- end
- elseif id == glue_code then
- if par.auto_breaking then
- local prev_p = cur_p.prev
- if prev_p and prev_p ~= temp_head then
- local id = prev_p.id
- if id == glyph_code or
- (id < math_code and (id ~= whatsit_code or prev_p.subtype ~= dir_code)) or -- was: precedes_break(prev_p)
- (id == kern_code and prev_p.subtype ~= userkern_code) then
- try_break(0, unhyphenated_code, par, first_p, cur_p, checked_expansion)
- end
- end
- end
- local spec = check_shrinkage(par,cur_p.spec)
- local order = stretch_orders[spec.stretch_order]
- cur_p.spec = spec
- active_width.size = active_width.size + spec.width
- active_width[order] = active_width[order] + spec.stretch
- active_width.shrink = active_width.shrink + spec.shrink
- elseif id == disc_code then
- local subtype = cur_p.subtype
- if subtype ~= second_disc_code then -- are there still second_disc_code in luatex
- local line_break_dir = par.line_break_dir
- if par.second_pass then -- todo: make second pass local
- local actual_pen = subtype == automatic_disc_code and par.ex_hyphen_penalty or par.hyphen_penalty
- local pre = cur_p.pre
- if not pre then -- trivial pre-break
- disc_width.size = 0
- if checked_expansion then
- disc_width.adjust_stretch = 0
- disc_width.adjust_shrink = 0
- end
- try_break(actual_pen, hyphenated_code, par, first_p, cur_p, checked_expansion)
- else
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
- disc_width.size = size
- active_width.size = active_width.size + size
- if checked_expansion then
- disc_width.adjust_stretch = adjust_stretch
- disc_width.adjust_shrink = adjust_shrink
- active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
- else
- -- disc_width.adjust_stretch = 0
- -- disc_width.adjust_shrink = 0
- end
- try_break(actual_pen, hyphenated_code, par, first_p, cur_p, checked_expansion)
- if subtype == first_disc_code then
- local cur_p_next = cur_p.next
- if cur_p_next.id ~= disc_code or cur_p_next.subtype ~= second_disc_code then
- report_parbuilders("unsupported disc at location %a",1)
- else
- local pre = cur_p_next.pre
- if pre then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,pre)
- disc_width.size = disc_width.size + size
- if checked_expansion then
- disc_width.adjust_stretch = disc_width.adjust_stretch + adjust_stretch
- disc_width.adjust_shrink = disc_width.adjust_shrink + adjust_shrink
- end
- try_break(actual_pen, hyphenated_code, par, first_p, cur_p_next, checked_expansion)
- --
- -- I will look into this some day ... comment in linebreak.w says that this fails,
- -- maybe this is what Taco means with his comment in the luatex manual.
- --
- -- do_one_seven_eight(sub_disc_width_from_active_width);
- -- do_one_seven_eight(reset_disc_width);
- -- s = vlink_no_break(vlink(cur_p));
- -- add_to_widths(s, line_break_dir, pdf_adjust_spacing,disc_width);
- -- ext_try_break(...,first_p,vlink(cur_p));
- --
- else
- report_parbuilders("unsupported disc at location %a",2)
- end
- end
- end
- -- beware, we cannot restore to a saved value as the try_break adapts active_width
- active_width.size = active_width.size - disc_width.size
- if checked_expansion then
- active_width.adjust_stretch = active_width.adjust_stretch - disc_width.adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink - disc_width.adjust_shrink
- end
- end
- end
- local replace = cur_p.replace
- if replace then
- local size, adjust_stretch, adjust_shrink = add_to_width(line_break_dir,checked_expansion,replace)
- active_width.size = active_width.size + size
- if checked_expansion then
- active_width.adjust_stretch = active_width.adjust_stretch + adjust_stretch
- active_width.adjust_shrink = active_width.adjust_shrink + adjust_shrink
- end
- end
- end
- elseif id == kern_code then
- if cur_p.subtype == userkern_code then
- kern_break(par,cur_p,first_p, checked_expansion)
- else
- active_width.size = active_width.size + cur_p.kern
- if checked_expansion and cur_p.subtype == kerning_code then
- local d = cur_p.kern
- if d ~= 0 then
- local stretch, shrink = kern_stretch_shrink(cur_p,d)
- active_width.adjust_stretch = active_width.adjust_stretch + stretch
- active_width.adjust_shrink = active_width.adjust_shrink + shrink
- end
- end
- end
- elseif id == math_code then
- par.auto_breaking = cur_p.subtype == endmath_code
- kern_break(par,cur_p, first_p, checked_expansion)
- elseif id == rule_code then
- active_width.size = active_width.size + cur_p.width
- elseif id == penalty_code then
- try_break(cur_p.penalty, unhyphenated_code, par, first_p, cur_p, checked_expansion)
- elseif id == whatsit_code then
- local subtype = cur_p.subtype
- if subtype == localpar_code then
- par.internal_pen_inter = cur_p.pen_inter
- par.internal_pen_broken = cur_p.pen_broken
- par.internal_left_box = cur_p.box_left
- par.internal_left_box_width = cur_p.box_left_width
- par.internal_right_box = cur_p.box_right
- par.internal_right_box_width = cur_p.box_right_width
- elseif subtype == dir_code then
- par.line_break_dir = checked_line_dir(dirstack) or par.line_break_dir
- else
- local get_width = get_whatsit_width[subtype]
- if get_width then
- active_width.size = active_width.size + get_width(cur_p)
- end
- end
- elseif id == mark_code or id == ins_code or id == adjust_code then
- -- skip
- else
- report_parbuilders("node of type %a found in paragraph",type(id))
- end
- cur_p = cur_p.next
- end
- if not cur_p then
- try_break(eject_penalty, hyphenated_code, par, first_p, cur_p, checked_expansion)
- local p_active = par.active
- local n_active = p_active.next
- if n_active ~= p_active then
- local r = n_active
- par.fewest_demerits = awful_badness
- repeat -- use local d
- if r.id ~= delta_code and r.total_demerits < par.fewest_demerits then
- par.fewest_demerits = r.total_demerits
- par.best_bet = r
- end
- r = r.next
- until r == p_active
- par.best_line = par.best_bet.line_number
- local asked_looseness = par.looseness
- if asked_looseness == 0 then
- return wrap_up(par)
- end
- local r = n_active
- local actual_looseness = 0
- -- minimize assignments to par but happens seldom
- repeat
- if r.id ~= delta_code then
- local line_diff = r.line_number - par.best_line
- par.line_diff = line_diff
- if (line_diff < actual_looseness and asked_looseness <= line_diff) or
- (line_diff > actual_looseness and asked_looseness >= line_diff) then
- par.best_bet = r
- actual_looseness = line_diff
- par.fewest_demerits = r.total_demerits
- elseif line_diff == actual_looseness and r.total_demerits < par.fewest_demerits then
- par.best_bet = r
- par.fewest_demerits = r.total_demerits
- end
- end
- r = r.next
- until r == p_active -- weird, loop list?
- par.best_line = par.best_bet.line_number
- if actual_looseness == asked_looseness or par.final_pass then
- return wrap_up(par)
- end
- end
- end
- reset_meta(par) -- clean up the memory by removing the break nodes
- if not par.second_pass then
- if tracing_paragraphs then
- diagnostics.current_pass(par,"secondpass")
- end
- par.threshold = par.tolerance
- par.second_pass = true
- par.final_pass = par.emergency_stretch <= 0
- else
- if tracing_paragraphs then
- diagnostics.current_pass(par,"emergencypass")
- end
- par.background.stretch = par.background.stretch + par.emergency_stretch
- par.final_pass = true
- end
- end
- return wrap_up(par)
-end
-
--- standard tex logging .. will be adapted .. missing font names and to many []
-
-local function write_esc(cs)
- local esc = tex.escapechar
- if esc then
- write("log",utfchar(esc),cs)
- else
- write("log",cs)
- end
-end
-
-function diagnostics.start()
-end
-
-function diagnostics.stop()
- write_nl("log",'')
-end
-
-function diagnostics.current_pass(par,what)
- write_nl("log",format("@%s",what))
-end
-
-local function short_display(a,font_in_short_display)
- while a do
- local id = a.id
- if id == glyph_code then
- local font = a.font
- if font ~= font_in_short_display then
- write("log",tex.fontidentifier(font) .. ' ')
- font_in_short_display = font
- end
- if a.subtype == ligature_code then
- font_in_short_display = short_display(a.components,font_in_short_display)
- else
- write("log",utfchar(a.char))
- end
--- elseif id == rule_code then
--- write("log","|")
--- elseif id == glue_code then
--- if a.spec.writable then
--- write("log"," ")
--- end
--- elseif id == math_code then
--- write("log","$")
- elseif id == disc_code then
- font_in_short_display = short_display(a.pre,font_in_short_display)
- font_in_short_display = short_display(a.post,font_in_short_display)
- else -- no explicit checking
- write("log",format("[%s]",nodecodes[id]))
- end
- a = a.next
- end
- return font_in_short_display
-end
-
-diagnostics.short_display = short_display
-
-function diagnostics.break_node(par, q, fit_class, break_type, cur_p) -- %d ?
- local passive = par.passive
- local typ_ind = break_type == hyphenated_code and '-' or ""
- if par.do_last_line_fit then
- local s = number.toscaled(q.active_short)
- local g = number.toscaled(q.active_glue)
- if cur_p then
- write_nl("log",format("@@%d: line %d.%d%s t=%s s=%s g=%s",
- passive.serial or 0,q.line_number-1,fit_class,typ_ind,q.total_demerits,s,g))
- else
- write_nl("log",format("@@%d: line %d.%d%s t=%s s=%s a=%s",
- passive.serial or 0,q.line_number-1,fit_class,typ_ind,q.total_demerits,s,g))
- end
- else
- write_nl("log",format("@@%d: line %d.%d%s t=%s",
- passive.serial or 0,q.line_number-1,fit_class,typ_ind,q.total_demerits))
- end
- if not passive.prev_break then
- write("log"," -> @0")
- else
- write("log",format(" -> @%d", passive.prev_break.serial or 0))
- end
-end
-
-function diagnostics.feasible_break(par, cur_p, r, b, pi, d, artificial_demerits)
- local printed_node = par.printed_node
- if printed_node ~= cur_p then
- write_nl("log","")
- if not cur_p then
- par.font_in_short_display = short_display(printed_node.next,par.font_in_short_display)
- else
- local save_link = cur_p.next
- cur_p.next = nil
- write_nl("log","")
- par.font_in_short_display = short_display(printed_node.next,par.font_in_short_display)
- cur_p.next = save_link
- end
- par.printed_node = cur_p
- end
- write_nl("log","@")
- if not cur_p then
- write_esc("par")
- else
- local id = cur_p.id
- if id == glue_code then
- -- print nothing
- elseif id == penalty_code then
- write_esc("penalty")
- elseif id == disc_code then
- write_esc("discretionary")
- elseif id == kern_code then
- write_esc("kern")
- elseif id == math_code then
- write_esc("math")
- else
- write_esc("unknown")
- end
- end
- local via, badness, demerits = 0, '*', '*'
- if r.break_node then
- via = r.break_node.serial or 0
- end
- if b <= infinite_badness then
- badness = tonumber(d) -- format("%d", b)
- end
- if not artificial_demerits then
- demerits = tonumber(d) -- format("%d", d)
- end
- write("log",format(" via @%d b=%s p=%s d=%s", via, badness, pi, demerits))
-end
-
--- reporting --
-
-statistics.register("alternative parbuilders", function()
- if nofpars > 0 then
- return format("%s paragraphs, %s lines (%s protruded, %s adjusted)", nofpars, noflines, nofprotrudedlines, nofadjustedlines)
- end
-end)
-
--- actually scaling kerns is not such a good idea and it will become
--- configureable
-
--- This is no way a replacement for the built in (fast) packer
--- it's just an alternative for special (testing) purposes.
---
--- We could use two hpacks: one to be used in the par builder
--- and one to be used for other purposes. The one in the par
--- builder is much more simple as it does not need the expansion
--- code but only need to register the effective expansion factor
--- with the glyph.
-
-local function glyph_width_height_depth(curdir,pdir,p)
- if is_rotated[curdir] then
- if is_parallel[curdir][pdir] then
- local half = (p.height + p.depth) / 2
- return p.width, half, half
- else
- local half = p.width / 2
- return p.height + p.depth, half, half
- end
- elseif is_rotated[pdir] then
- if is_parallel[curdir][pdir] then
- local half = (p.height + p.depth) / 2
- return p.width, half, half
- else
- return p.height + p.depth, p.width, 0 -- weird
- end
- else
- if glyphdir_is_equal[curdir][pdir] then
- return p.width, p.height, p.depth
- elseif is_opposite[curdir][pdir] then
- return p.width, p.depth, p.height
- else -- can this happen?
- return p.height + p.depth, p.width, 0 -- weird
- end
- end
-end
-
-local function pack_width_height_depth(curdir,pdir,p)
- if is_rotated[curdir] then
- if is_parallel[curdir][pdir] then
- local half = (p.height + p.depth) / 2
- return p.width, half, half
- else -- can this happen?
- local half = p.width / 2
- return p.height + p.depth, half, half
- end
- else
- if pardir_is_equal[curdir][pdir] then
- return p.width, p.height, p.depth
- elseif is_opposite[curdir][pdir] then
- return p.width, p.depth, p.height
- else -- weird dimensions, can this happen?
- -- return p.width, p.depth, p.height
- return p.height + p.depth, p.width, 0
- end
- end
-end
-
--- local function xpack(head,width,method,direction,analysis)
---
--- -- inspect(analysis)
---
--- local expansion = method == "cal_expand_ratio"
--- local natural = analysis.size
--- local font_stretch = analysis.adjust_stretch
--- local font_shrink = analysis.adjust_shrink
--- local font_expand_ratio = 0
--- local delta = width - natural
---
--- local hlist = new_node("hlist")
---
--- hlist.list = head
--- hlist.dir = direction or tex.textdir
--- hlist.width = width
--- hlist.height = height
--- hlist.depth = depth
---
--- if delta == 0 then
---
--- hlist.glue_sign = 0
--- hlist.glue_order = 0
--- hlist.glue_set = 0
---
--- else
---
--- local order = analysis.filll ~= 0 and fillcodes.filll or
--- analysis.fill ~= 0 and fillcodes.fill or
--- analysis.fil ~= 0 and fillcodes.fil or
--- analysis.fi ~= 0 and fillcodes.fi or 0
---
--- if delta > 0 then
---
--- if expansion and order == 0 and font_stretch > 0 then
--- font_expand_ratio = (delta/font_stretch) * 1000
--- else
--- local stretch = analysis.stretch
--- if stretch ~= 0 then
--- hlist.glue_sign = 1 -- stretch
--- hlist.glue_order = order
--- hlist.glue_set = delta/stretch
--- else
--- hlist.glue_sign = 0 -- nothing
--- hlist.glue_order = order
--- hlist.glue_set = 0
--- end
--- end
--- print("stretch",hlist.glue_sign,hlist.glue_order,hlist.glue_set)
---
--- else
---
--- if expansion and order == 0 and font_shrink > 0 then
--- font_expand_ratio = (delta/font_shrink) * 1000
--- else
--- local shrink = analysis.shrink
--- if shrink ~= 0 then
--- hlist.glue_sign = 2 -- shrink
--- hlist.glue_order = order
--- hlist.glue_set = - delta/shrink
--- else
--- hlist.glue_sign = 0 -- nothing
--- hlist.glue_order = order
--- hlist.glue_set = 0
--- end
--- end
--- print("shrink",hlist.glue_sign,hlist.glue_order,hlist.glue_set)
---
--- end
---
--- end
---
--- if not expansion or font_expand_ratio == 0 then
--- -- nothing
--- elseif font_expand_ratio > 0 then
--- if font_expand_ratio > 1000 then
--- font_expand_ratio = 1000
--- end
--- local current = head
--- while current do
--- local id = current.id
--- if id == glyph_code then
--- local stretch, shrink = char_stretch_shrink(current) -- get only one
--- if stretch then
--- if trace_expansion then
--- setnodecolor(g,"hz:positive")
--- end
--- current.expansion_factor = font_expand_ratio * stretch
--- end
--- elseif id == kern_code then
--- local kern = current.kern
--- if kern ~= 0 and current.subtype == kerning_code then
--- current.kern = font_expand_ratio * current.kern
--- end
--- end
--- current = current.next
--- end
--- elseif font_expand_ratio < 0 then
--- if font_expand_ratio < -1000 then
--- font_expand_ratio = -1000
--- end
--- local current = head
--- while current do
--- local id = current.id
--- if id == glyph_code then
--- local stretch, shrink = char_stretch_shrink(current) -- get only one
--- if shrink then
--- if trace_expansion then
--- setnodecolor(g,"hz:negative")
--- end
--- current.expansion_factor = font_expand_ratio * shrink
--- end
--- elseif id == kern_code then
--- local kern = current.kern
--- if kern ~= 0 and current.subtype == kerning_code then
--- current.kern = font_expand_ratio * current.kern
--- end
--- end
--- current = current.next
--- end
--- end
--- return hlist, 0
--- end
-
--- local expansion_stack = { } -- no dealloc
-
-local function hpack(head,width,method,direction) -- fast version when head = nil
-
- -- we can pass the adjust_width and adjust_height so that we don't need to recalculate them but
- -- with the glue mess it's less trivial as we lack detail
-
- local hlist = new_node("hlist")
-
- if head == nil then
- return hlist, 0
- end
-
- local cal_expand_ratio = method == "cal_expand_ratio" -- "subst_ex_font" -- is gone
-
- direction = direction or tex.textdir
-
- local pack_begin_line = 0
- local line = 0
-
- local height = 0
- local depth = 0
- local natural = 0
- local font_stretch = 0
- local font_shrink = 0
- local font_expand_ratio = 0
- local last_badness = 0
- local disc_stack = { }
- local disc_level = 0
- local expansion_stack = cal_expand_ratio and { } -- todo: optionally pass this
- local expansion_index = 0
- local total_stretch = { [0] = 0, 0, 0, 0, 0 }
- local total_shrink = { [0] = 0, 0, 0, 0, 0 }
-
- local hpack_dir = direction
-
- local adjust_head = texlists.adjust_head
- local pre_adjust_head = texlists.pre_adjust_head
- local adjust_tail = adjust_head and slide_nodes(adjust_head)
- local pre_adjust_tail = pre_adjust_head and slide_nodes(pre_adjust_head)
-
- hlist.list = head
- hlist.dir = hpack_dir
-
- new_dir_stack(hpack_dir)
-
- local checked_expansion = false
-
- if cal_expand_ratio then
- checked_expansion = { }
- setmetatableindex(checked_expansion,check_expand_lines)
- end
-
- -- this one also needs to check the font, so in the end indeed we might end up with two variants
-
- local fontexps, lastfont
-
- local current = head
-
- while current do
- local id = current.id
- if id == glyph_code then
- if cal_expand_ratio then
- local currentfont = current.font
- if currentfont ~= lastfont then
- fontexps = checked_expansion[currentfont] -- a bit redundant for the par line packer
- lastfont = currentfont
- end
- if fontexps then
- local expansion = fontexps[current.char]
- if expansion then
- font_stretch = font_stretch + expansion.glyphstretch
- font_shrink = font_shrink + expansion.glyphshrink
- expansion_index = expansion_index + 1
- expansion_stack[expansion_index] = current
- end
- end
- end
- -- use inline if no expansion
- local wd, ht, dp = glyph_width_height_depth(hpack_dir,"TLT",current) -- was TRT ?
- natural = natural + wd
- if ht > height then
- height = ht
- end
- if dp > depth then
- depth = dp
- end
- current = current.next
- elseif id == kern_code then
- local kern = current.kern
- if kern == 0 then
- -- no kern
- elseif current.subtype == kerning_code then -- check p.kern
- if cal_expand_ratio then
- local stretch, shrink = kern_stretch_shrink(current,kern)
- font_stretch = font_stretch + stretch
- font_shrink = font_shrink + shrink
- expansion_index = expansion_index + 1
- expansion_stack[expansion_index] = current
- end
- natural = natural + kern
- else
- natural = natural + kern
- end
- current = current.next
- elseif id == disc_code then
- if current.subtype ~= second_disc_code then
- -- todo : local stretch, shrink = char_stretch_shrink(s)
- local replace = current.replace
- if replace then
- disc_level = disc_level + 1
- disc_stack[disc_level] = current.next
- current = replace
- else
- current = current.next
- end
- else
- -- -- pre post replace
- --
- -- local stretch, shrink = char_stretch_shrink(current.pre)
- -- font_stretch = font_stretch + stretch
- -- font_shrink = font_shrink + shrink
- -- expansion_index = expansion_index + 1
- -- expansion_stack[expansion_index] = current.pre
- --
- current = current.next
- end
- elseif id == glue_code then
- local spec = current.spec
- natural = natural + spec.width
- local op = spec.stretch_order
- local om = spec.shrink_order
- total_stretch[op] = total_stretch[op] + spec.stretch
- total_shrink [om] = total_shrink [om] + spec.shrink
- if current.subtype >= leaders_code then
- local leader = current.leader
- local ht = leader.height
- local dp = leader.depth
- if ht > height then
- height = ht
- end
- if dp > depth then
- depth = dp
- end
- end
- current = current.next
- elseif id == hlist_code or id == vlist_code then
- local sh = current.shift
- local wd, ht, dp = pack_width_height_depth(hpack_dir,current.dir or hpack_dir,current) -- added: or pack_dir
- local hs, ds = ht - sh, dp + sh
- natural = natural + wd
- if hs > height then
- height = hs
- end
- if ds > depth then
- depth = ds
- end
- current = current.next
- elseif id == rule_code then
- local wd = current.width
- local ht = current.height
- local dp = current.depth
- natural = natural + wd
- if ht > height then
- height = ht
- end
- if dp > depth then
- depth = dp
- end
- current = current.next
- elseif id == math_code then
- natural = natural + current.surround
- current = current.next
- elseif id == unset_code then
- local wd = current.width
- local ht = current.height
- local dp = current.depth
- local sh = current.shift
- local hs = ht - sh
- local ds = dp + sh
- natural = natural + wd
- if hs > height then
- height = hs
- end
- if ds > depth then
- depth = ds
- end
- current = current.next
- elseif id == ins_code or id == mark_code then
- local prev = current.prev
- local next = current.next
- if adjust_tail then -- todo
- if next then
- next.prev = prev
- end
- if prev then
- prev.next = next
- end
- current.prev = adjust_tail
- current.next = nil
- adjust_tail.next = current
- adjust_tail = current
- else
- adjust_head = current
- adjust_tail = current
- current.prev = nil
- current.next = nil
- end
- current = next
- elseif id == adjust_code then
- local list = current.list
- if adjust_tail then
- adjust_tail.next = list
- adjust_tail = slide_nodes(list)
- else
- adjust_head = list
- adjust_tail = slide_nodes(list)
- end
- current = current.next
- elseif id == whatsit_code then
- local subtype = current.subtype
- if subtype == dir_code then
- hpack_dir = checked_line_dir(stack,current) or hpack_dir
- else
- local get_dimensions = get_whatsit_dimensions[subtype]
- if get_dimensions then
- local wd, ht, dp = get_dimensions(current)
- natural = natural + wd
- if ht > height then
- height = ht
- end
- if dp > depth then
- depth = dp
- end
- end
- end
- current = current.next
- elseif id == marginkern_code then
- if cal_expand_ratio then
- local glyph = current.glyph
- local char_pw = current.subtype == leftmargin_code and left_pw or right_pw
- font_stretch = font_stretch - current.width - char_pw(glyph)
- font_shrink = font_shrink - current.width - char_pw(glyph)
- expansion_index = expansion_index + 1
- expansion_stack[expansion_index] = glyph
- end
- natural = natural + current.width
- current = current.next
- else
- current = current.next
- end
- if not current and disc_level > 0 then
- current = disc_stack[disc_level]
- disc_level = disc_level - 1
- end
- end
- if adjust_tail then
- adjust_tail.next = nil -- todo
- end
- if pre_adjust_tail then
- pre_adjust_tail.next = nil -- todo
- end
- if mode == "additional" then
- width = width + natural
- end
- hlist.width = width
- hlist.height = height
- hlist.depth = depth
- local delta = width - natural
- if delta == 0 then
- hlist.glue_sign = 0
- hlist.glue_order = 0
- hlist.glue_set = 0
- elseif delta > 0 then
- local order = (total_stretch[4] ~= 0 and 4 or total_stretch[3] ~= 0 and 3) or
- (total_stretch[2] ~= 0 and 2 or total_stretch[1] ~= 0 and 1) or 0
- if cal_expand_ratio and order == 0 and font_stretch > 0 then
- font_expand_ratio = (delta/font_stretch) * 1000 -- round(delta/font_stretch * 1000)
- else
- local tso = total_stretch[order]
- if tso ~= 0 then
- hlist.glue_sign = 1
- hlist.glue_order = order
- hlist.glue_set = delta/tso
- else
- hlist.glue_sign = 0
- hlist.glue_order = order
- hlist.glue_set = 0
- end
--- print("stretch",hlist.glue_sign,hlist.glue_order,hlist.glue_set)
- if order == 0 and hlist.list then
- last_badness = calculate_badness(delta,total_stretch[0])
- if last_badness > tex.hbadness then
- if last_badness > 100 then
- diagnostics.underfull_hbox(hlist,pack_begin_line,line,last_badness)
- else
- diagnostics.loose_hbox(hlist,pack_begin_line,line,last_badness)
- end
- end
- end
- end
- else
- local order = total_shrink[4] ~= 0 and 4 or total_shrink[3] ~= 0 and 3
- or total_shrink[2] ~= 0 and 2 or total_shrink[1] ~= 0 and 1 or 0
- if cal_expand_ratio and order == 0 and font_shrink > 0 then
- font_expand_ratio = (delta/font_shrink) * 1000 -- round(delta/font_shrink * 1000)
- else -- why was this else commented
- local tso = total_shrink[order]
- if tso ~= 0 then
- hlist.glue_sign = 2
- hlist.glue_order = order
- hlist.glue_set = -delta/tso
- else
- hlist.glue_sign = 0
- hlist.glue_order = order
- hlist.glue_set = 0
- end
--- print("shrink",hlist.glue_sign,hlist.glue_order,hlist.glue_set)
- if total_shrink[order] < -delta and order == 0 and hlist.list then
- last_badness = 1000000
- hlist.glue_set = 1
- local fuzz = - delta - total_shrink[0]
- local hfuzz = tex.hfuzz
- if fuzz > hfuzz or tex.hbadness < 100 then
- local overfullrule = tex.overfullrule
- if fuzz > hfuzz and overfullrule > 0 then
- -- weird, is always called and no rules shows up
- slide_nodes(list).next = new_rule(overfullrule,nil,nil,hlist.dir)
- end
- diagnostics.overfull_hbox(hlist,pack_begin_line,line,-delta) -- - added
- end
- elseif order == 0 and hlist.list and last_badness > tex.hbadness then
- diagnostics.bad_hbox(hlist,pack_begin_line,line,last_badness)
- end
- end
- end
- if cal_expand_ratio and font_expand_ratio ~= 0 then
- -- if font_expand_ratio > 1000 then
- -- font_expand_ratio = 1000
- -- elseif font_expand_ratio < -1000 then
- -- font_expand_ratio = -1000
- -- end
-
- local fontexps, lastfont
-
- if font_expand_ratio > 0 then
- for i=1,expansion_index do
- local g = expansion_stack[i]
- if g.id == glyph_code then
- local currentfont = g.font
- if currentfont ~= lastfont then
- fontexps = expansions[currentfont]
- lastfont = currentfont
- end
- local data = fontexps[g.char]
- if trace_expansion then
- setnodecolor(g,"hz:positive")
- end
- g.expansion_factor = font_expand_ratio * data.glyphstretch
- else
- local stretch, shrink = kern_stretch_shrink(g,g.kern)
- g.expansion_factor = font_expand_ratio * stretch
- end
- end
- else
- for i=1,expansion_index do
- local g = expansion_stack[i]
- if g.id == glyph_code then
- local currentfont = g.font
- if currentfont ~= lastfont then
- fontexps = expansions[currentfont]
- lastfont = currentfont
- end
- local data = fontexps[g.char]
- if trace_expansion then
- setnodecolor(g,"hz:negative")
- end
- g.expansion_factor = font_expand_ratio * data.glyphshrink
- else
- local stretch, shrink = kern_stretch_shrink(g,g.kern)
- g.expansion_factor = font_expand_ratio * shrink
- end
- end
- end
-
- end
- return hlist, last_badness
-end
-
-nodes.hpack = hpack
-hpack_nodes = hpack -- comment this for old fashioned expansion
-xpack_nodes = hpack -- comment this for old fashioned expansion
-
-local function common_message(hlist,pack_begin_line,line,str)
- write_nl("")
- if status.output_active then -- unset
- write(str," has occurred while \\output is active")
- end
- if pack_begin_line > 0 then
- write(str," in paragraph at lines ",pack_begin_line,"--",line)
- elseif pack_begin_line < 0 then
- write(str," in alignment at lines ",-pack_begin_line,"--",line)
- else
- write(str," detected at line ",line)
- end
- write_nl("")
- diagnostics.short_display(hlist.list,false)
- write_nl("")
- -- diagnostics.start()
- -- show_box(hlist.list)
- -- diagnostics.stop()
-end
-
-function diagnostics.overfull_hbox(hlist,pack_begin_line,line,d)
- common_message(hlist,pack_begin_line,line,format("Overfull \\hbox (%spt too wide)",number.toscaled(d)))
-end
-
-function diagnostics.bad_hbox(hlist,pack_begin_line,line,b)
- common_message(hlist,pack_begin_line,line,format("Tight \\hbox (badness %i)",b))
-end
-
-function diagnostics.underfull_hbox(hlist,pack_begin_line,line,b)
- common_message(hlist,pack_begin_line,line,format("Underfull \\hbox (badness %i)",b))
-end
-
-function diagnostics.loose_hbox(hlist,pack_begin_line,line,b)
- common_message(hlist,pack_begin_line,line,format("Loose \\hbox (badness %i)",b))
-end
-
--- for the moment here:
-
-local utfchar = utf.char
-local concat = table.concat
-
-local nodecodes = nodes.nodecodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local glyph_code = nodecodes.glyph
-local kern_code = nodecodes.kern
-local setnodecolor = nodes.tracers.colors.set
-local parameters = fonts.hashes.parameters
-local basepoints = number.basepoints
-
--- definecolor[hz:positive] [r=0.6]
--- definecolor[hz:negative] [g=0.6]
--- definecolor[hz:zero] [b=0.6]
-
--- scale = multiplier + ef/multiplier
-
-local trace_verbose = false trackers.register("builders.paragraphs.expansion.verbose", function(v) trace_verbose = v end)
-
-local report_verbose = logs.reporter("fonts","expansion")
-
-local function colorize(n)
- local size, font, ef, width, scale, list, flush, length
- if trace_verbose then
- width = 0
- length = 0
- list = { }
- flush = function()
- if length > 0 then
- report_verbose("%0.3f : %10s %10s %s",scale,basepoints(width),basepoints(width*scale),concat(list,"",1,length))
- width = 0
- length = 0
- end
- end
- else
- length = 0
- end
- -- tricky: the built-in method creates dummy fonts and the last line normally has the
- -- original font and that one then has ex.auto set
- while n do
- local id = n.id
- if id == glyph_code then
- local ne = n.expansion_factor
- if ne == 0 then
- if length > 0 then flush() end
- else
- local f = n.font
- if f ~= font then
- if length > 0 then
- flush()
- end
- local pf = parameters[f]
- local ex = pf.expansion
- if ex and ex.auto then
- size = pf.size
- font = f -- save lookups
- else
- size = false
- end
- end
- if size then
- if ne ~= ef then
- if length > 0 then
- flush()
- end
- ef = ne
- end
- -- scale = 1.0 + ef / 1000 / 1000 / 1000
- scale = 1.0 + ef / 1000000000
- if scale > 1 then
- setnodecolor(n,"hz:positive")
- elseif scale < 1 then
- setnodecolor(n,"hz:negative")
- else
- setnodecolor(n,"hz:zero")
- end
- if report_verbose then
- length = length + 1
- list[length] = utfchar(n.char)
- width = width + n.width -- no kerning yet
- end
- end
- end
- elseif id == hlist_code or id == vlist_code then
- if length > 0 then
- flush()
- end
- colorize(n.list,flush)
- else -- nothing to show on kerns
- if length > 0 then
- flush()
- end
- end
- n = n.next
- end
- if length > 0 then
- flush()
- end
-end
-
-builders.paragraphs.expansion = builders.paragraphs.expansion or { }
-
-function builders.paragraphs.expansion.trace(head)
- colorize(head,true)
- return head
-end
-
-local tasks = nodes.tasks
-
-tasks.prependaction("shipouts","normalizers","builders.paragraphs.expansion.trace")
-tasks.disableaction("shipouts","builders.paragraphs.expansion.trace")
-
-trackers.register("builders.paragraphs.expansion.verbose", function(v)
- if v then
- tasks.enableaction("shipouts","builders.paragraphs.expansion.trace")
- else
- tasks.disableaction("shipouts","builders.paragraphs.expansion.trace")
- end
-end)
diff --git a/tex/context/base/node-met.lua b/tex/context/base/node-met.lua
deleted file mode 100644
index d6b3df213..000000000
--- a/tex/context/base/node-met.lua
+++ /dev/null
@@ -1,669 +0,0 @@
-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",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- This is an experimental module. Don't use nuts for generic code, at least not till
--- the regular code is proven stable. No support otherwise.
-
--- luatex: todo: copylist should return h, t
--- todo: see if using insert_before and insert_after makes sense here
-
--- This file is a side effect of the \LUATEX\ speed optimization project of Luigi
--- Scarso and me. As \CONTEXT\ spends over half its time in \LUA, we though that
--- using \LUAJIT\ could improve performance. We've published some of our experiences
--- elsewhere, but to summarize: \LUAJITTEX\ benefits a lot from the faster virtual
--- machine, but when jit is turned of we loose some again. We experimented with
--- ffi (without messing up the \CONTEXT\ code too much) but there we also lost more
--- than we gained (mostly due to lack of compatible userdata support: it's all or
--- nothing). This made us decide to look into the \LUA||\TEX\ interfacing and by
--- profiling and careful looking at the (of course then still beta source code) we
--- could come up with some improvements. The first showed up in 0.75 and we've more
--- on the agenda for 0.80. Although some interfaces could be sped up significantly
--- in practice we're only talking of 5||10\% on a \CONTEXT\ run and maybe more when
--- complex and extensive node list manipulations happens (we're talking of hundreds
--- of millions cross boundary calls then for documents of hundreds pages). One of the
--- changes in the \CONTEXT\ code base is that we went from indexed access to nodes to
--- function calls (in principle faster weren't it that the accessors need to do more
--- checking which makes them slower) and from there to optimizing these calls as well
--- as providing fast variants for well defined situations. At first optimizations were
--- put in a separate \type {node.fast} table although some improvements could be
--- ported to the main node functions. Because we got the feeling that more gain was
--- possible (especially when using more complex fonts and \MKIV\ functionality) we
--- eventually abandoned this approach and dropped the \type {fast} table in favour of
--- another hack. In the process we had done lots of profiling and testing so we knew
--- where time was wasted,
---
--- As lots of testing and experimenting was part of this project, I could not have
--- done without stacks of new \CD s and \DVD s. This time Porcupine Tree, No-Man
--- and Archive were came to rescue.
-
-local type, select = type, select
-local setmetatableindex = table.setmetatableindex
-
--- First we get the metatable of a node:
-
-local metatable = nil
-
-do
- local glyph = node.new("glyph",0)
- metatable = getmetatable(glyph)
- node.free(glyph)
-end
-
--- statistics.tracefunction(node, "node", "getfield","setfield")
--- statistics.tracefunction(node.direct,"node.direct","getfield","setfield")
-
--- We start with some helpers and provide all relevant basic functions in the
--- node namespace as well.
-
-local gonuts = type(node.direct) == "table"
--- local gonuts = false
-
-nodes = nodes or { }
-local nodes = nodes
-
-nodes.gonuts = gonuts
-
-local nodecodes = nodes.codes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-
-nodes.tostring = node.tostring or tostring
-nodes.copy = node.copy
-nodes.copy_list = node.copy_list
-nodes.delete = node.delete
-nodes.dimensions = node.dimensions
-nodes.end_of_math = node.end_of_math
-nodes.flush_list = node.flush_list
-nodes.flush_node = node.flush_node
-nodes.free = node.free
-nodes.insert_after = node.insert_after
-nodes.insert_before = node.insert_before
-nodes.hpack = node.hpack
-nodes.new = node.new
-nodes.tail = node.tail
-nodes.traverse = node.traverse
-nodes.traverse_id = node.traverse_id
-nodes.slide = node.slide
-nodes.vpack = node.vpack
-nodes.fields = node.fields
-
-nodes.first_glyph = node.first_glyph
-nodes.first_character = node.first_character
-nodes.has_glyph = node.has_glyph or node.first_glyph
-
-nodes.current_attr = node.current_attr
-nodes.do_ligature_n = node.do_ligature_n
-nodes.has_field = node.has_field
-nodes.last_node = node.last_node
-nodes.usedlist = node.usedlist
-nodes.protrusion_skippable = node.protrusion_skippable
-nodes.write = node.write
-
-nodes.has_attribute = node.has_attribute
-nodes.set_attribute = node.set_attribute
-nodes.unset_attribute = node.unset_attribute
-
-nodes.protect_glyphs = node.protect_glyphs
-nodes.unprotect_glyphs = node.unprotect_glyphs
-nodes.kerning = node.kerning
-nodes.ligaturing = node.ligaturing
-nodes.mlist_to_hlist = node.mlist_to_hlist
-
-if not gonuts or not node.getfield then
- node.getfield = metatable.__index
- node.setfield = metatable.__newindex
-end
-
--- if gonuts then
- nodes.tonode = function(n) return n end
- nodes.tonut = function(n) return n end
--- end
-
-local getfield = node.getfield
-local setfield = node.setfield
-
-local getattr = getfield
-local setattr = setfield
-
-local getnext = node.getnext or function(n) return getfield(n,"next") end
-local getprev = node.getprev or function(n) return getfield(n,"prev") end
-local getid = node.getid or function(n) return getfield(n,"id") end
-local getchar = node.getchar or function(n) return getfield(n,"char") end
-local getfont = node.getfont or function(n) return getfield(n,"font") end
-local getsubtype = node.getsubtype or function(n) return getfield(n,"subtype") end
-local getlist = node.getlist or function(n) return getfield(n,"list") end
-local getleader = node.getleader or function(n) return getfield(n,"leader") end
-
-nodes.getfield = getfield
-nodes.getattr = getattr
-
-nodes.setfield = setfield
-nodes.setattr = setattr
-
-nodes.getnext = getnext
-nodes.getprev = getprev
-nodes.getid = getid
-nodes.getchar = getchar
-nodes.getfont = getfont
-nodes.getsubtype = getsubtype
-nodes.getlist = getlist
-nodes.getleader = getleader
-
-nodes.getbox = node.getbox or tex.getbox
-nodes.setbox = node.setbox or tex.setbox
-nodes.getskip = node.getskip or tex.get
-
-local n_new_node = nodes.new
-local n_free_node = nodes.free
-local n_setfield = nodes.setfield
-local n_getfield = nodes.getfield
-local n_getnext = nodes.getnext
-local n_getprev = nodes.getprev
-local n_getid = nodes.getid
-local n_getlist = nodes.getlist
-local n_copy_node = nodes.copy
-local n_copy_list = nodes.copy_list
-local n_find_tail = nodes.tail
-local n_insert_after = nodes.insert_after
-local n_insert_before = nodes.insert_before
-local n_slide = nodes.slide
-
-local n_remove_node = node.remove -- not yet nodes.remove
-
--- if t.id == glue_code then
--- local s = t.spec
--- if s and s.writable then
--- free_node(s)
--- end
--- t.spec = nil
--- end
-
-local function remove(head,current,free_too)
- local t = current
- head, current = n_remove_node(head,current)
- if t then
- if free_too then
- n_free_node(t)
- t = nil
- else
- n_setfield(t,"next",nil)
- n_setfield(t,"prev",nil)
- end
- end
- return head, current, t
-end
-
-nodes.remove = remove
-
-function nodes.delete(head,current)
- return remove(head,current,true)
-end
-
--- local h, c = nodes.replace(head,current,new)
--- local c = nodes.replace(false,current,new)
--- local c = nodes.replace(current,new)
---
--- todo: check for new.next and find tail
-
-function nodes.replace(head,current,new) -- no head returned if false
- if not new then
- head, current, new = false, head, current
--- current, new = head, current
- end
- local prev = n_getprev(current)
- local next = n_getnext(current)
- if next then
- n_setfield(new,"next",next)
- n_setfield(next,"prev",new)
- end
- if prev then
- n_setfield(new,"prev",prev)
- n_setfield(prev,"next",new)
- end
- if head then
- if head == current then
- head = new
- end
- n_free_node(current)
- return head, new
- else
- n_free_node(current)
- return new
- end
-end
-
-local function count(stack,flat)
- local n = 0
- while stack do
- local id = n_getid(stack)
- if not flat and id == hlist_code or id == vlist_code then
- local list = n_getlist(stack)
- if list then
- n = n + 1 + count(list) -- self counts too
- else
- n = n + 1
- end
- else
- n = n + 1
- end
- stack = n_getnext(stack)
- end
- return n
-end
-
-nodes.count = count
-
-function nodes.append(head,current,...)
- for i=1,select("#",...) do
- head, current = n_insert_after(head,current,(select(i,...)))
- end
- return head, current
-end
-
-function nodes.prepend(head,current,...)
- for i=1,select("#",...) do
- head, current = n_insert_before(head,current,(select(i,...)))
- end
- return head, current
-end
-
-function nodes.linked(...)
- local head, last
- for i=1,select("#",...) do
- local next = select(i,...)
- if next then
- if head then
- n_setfield(last,"next",next)
- n_setfield(next,"prev",last)
- else
- head = next
- end
- last = n_find_tail(next) -- we could skip the last one
- end
- end
- return head
-end
-
-function nodes.concat(list) -- consider tail instead of slide
- local head, tail
- for i=1,#list do
- local li = list[i]
- if li then
- if head then
- n_setfield(tail,"next",li)
- n_setfield(li,"prev",tail)
- else
- head = li
- end
- tail = n_slide(li)
- end
- end
- return head, tail
-end
-
---[[
-At some point we ran into a problem that the glue specification
-of the zeropoint dimension was overwritten when adapting a glue spec
-node. This is a side effect of glue specs being shared. After a
-couple of hours tracing and debugging Taco and I came to the
-conclusion that it made no sense to complicate the spec allocator
-and settled on a writable flag. This all is a side effect of the
-fact that some glues use reserved memory slots (with the zeropoint
-glue being a noticeable one). So, next we wrap this into a function
-and hide it for the user. And yes, LuaTeX now gives a warning as
-well.
-]]--
-
-function nodes.writable_spec(n) -- not pool
- local spec = n_getfield(n,"spec")
- if not spec then
- spec = n_copy_node(glue_spec)
- n_setfield(n,"spec",spec)
- elseif not n_getfield(spec,"writable") then
- spec = n_copy_node(spec)
- n_setfield(n,"spec",spec)
- end
- return spec
-end
-
-if gonuts then
-
- function nodes.reference(n)
- return n and tonut(n) or ""
- end
-
-else
-
- local left, space = lpeg.P("<"), lpeg.P(" ")
-
- local reference = left * (1-left)^0 * left * space^0 * lpeg.C((1-space)^0)
-
- function nodes.reference(n)
- return n and lpegmatch(reference,tostring(n)) or ""
- end
-
-end
-
--- Here starts an experiment with metatables. Of course this only works with nodes
--- wrapped in userdata with a metatable.
---
--- Nodes are kind of special in the sense that you need to keep an eye on creation
--- and destruction. This is quite natural if you consider that changing the content
--- of a node would also change any copy (or alias). As there are too many pitfalls
--- we don't have this kind of support built in \LUATEX, which means that macro
--- packages are free to provide their own. One can even use local variants.
---
--- n1 .. n2 : append nodes, no copies
--- n1 * 5 : append 4 copies of nodes
--- 5 + n1 : strip first 5 nodes
--- n1 - 5 : strip last 5 nodes
--- n1 + n2 : inject n2 after first of n1
--- n1 - n2 : inject n2 before last of n1
--- n1^2 : two copies of nodes (keep orginal)
--- - n1 : reverse nodes
--- n1/f : apply function to nodes
-
--- local s = nodes.typesetters.tonodes
---
--- local function w(lst)
--- context.dontleavehmode()
--- context(lst)
--- context.par()
--- end
---
--- local n1 = s("a")
--- local n2 = s("b")
--- local n3 = s("c")
--- local n4 = s("d")
--- local n5 = s("e")
--- local n6 = s("f")
--- local n7 = s("g")
---
--- local n0 = n1 .. (n2 * 10).. n3 .. (5 * n4) .. n5 .. ( 5 * n6 ) .. n7 / function(n) n.char = string.byte("!") return n end
---
--- w(#n0)
---
--- w(n0)
---
--- local n1 = s("a") * 10
--- local n2 = s("b") * 10
---
--- local n0 = ((5 + n1) .. (n2 - 5) )
--- local n0 = - n0
---
--- local n0 = nil .. n0^3 .. nil
---
--- w(n0)
---
--- w ( s("a") + s("b") ) w ( s("a") + 4*s("b") ) w ( 4*s("a") + s("b") ) w ( 4*s("a") + 4*s("b") )
--- w ( s("a") - s("b") ) w ( s("a") - 4*s("b") ) w ( 4*s("a") - s("b") ) w ( 4*s("a") - 4*s("b") )
-
-local n_remove_node = nodes.remove
-
-metatable.__concat = function(n1,n2) -- todo: accept nut on one end
- if not n1 then
- return n2
- elseif not n2 then
- return n1
- elseif n1 == n2 then
- -- or abort
- return n2 -- or n2 * 2
- else
- local tail = n_find_tail(n1)
- n_setfield(tail,"next",n2)
- n_setfield(n2,"prev",tail)
- return n1
- end
-end
-
-metatable.__mul = function(n,multiplier)
- if type(multiplier) ~= "number" then
- n, multiplier = multiplier, n
- end
- if multiplier <= 1 then
- return n
- elseif n_getnext(n) then
- local head
- for i=2,multiplier do
- local h = n_copy_list(n)
- if head then
- local t = n_find_tail(h)
- n_setfield(t,"next",head)
- n_setfield(head,"prev",t)
- end
- head = h
- end
- local t = n_find_tail(n)
- n_setfield(t,"next",head)
- n_setfield(head,"prev",t)
- else
- local head
- for i=2,multiplier do
- local c = n_copy_node(n)
- if head then
- n_setfield(c,"next",head)
- n_setfield(head,"prev",c)
- end
- head = c
- end
- n_setfield(n,"next",head)
- n_setfield(head,"prev",n)
- end
- return n
-end
-
-metatable.__sub = function(first,second)
- if type(second) == "number" then
- local tail = n_find_tail(first)
- for i=1,second do
- local prev = n_getfield(tail,"prev")
- n_free_node(tail) -- can become flushlist/flushnode
- if prev then
- tail = prev
- else
- return nil
- end
- end
- if tail then
- n_setfield(tail,"next",nil)
- return first
- else
- return nil
- end
- else
- -- aaaaa - bbb => aaaabbba
- local firsttail = n_find_tail(first)
- local prev = n_getprev(firsttail)
- if prev then
- local secondtail = n_find_tail(second)
- n_setfield(secondtail,"next",firsttail)
- n_setfield(firsttail,"prev",ltail)
- n_setfield(prev,"next",second)
- n_setfield(second,"prev",prev)
- return first
- else
- local secondtail = n_find_tail(second)
- n_setfield(secondtail,"next",first)
- n_setfield(first,"prev",ltail)
- return second
- end
- end
-end
-
-metatable.__add = function(first,second)
- if type(first) == "number" then
- local head = second
- for i=1,first do
- local second = n_getnext(head)
- n_free_node(head) -- can become flushlist/flushnode
- if second then
- head = second
- else
- return nil
- end
- end
- if head then
- n_setfield(head,"prev",nil)
- return head
- else
- return nil
- end
- else
- -- aaaaa + bbb => abbbaaaa
- local next = n_getnext(first)
- if next then
- local secondtail = n_find_tail(second)
- n_setfield(first,"next",second)
- n_setfield(second,"prev",first)
- n_setfield(secondtail,"next",next)
- n_setfield(next,"prev",secondtail)
- else
- n_setfield(first,"next",second)
- n_setfield(second,"prev",first)
- end
- return first
- end
-end
-
-metatable.__len = function(current)
- local length = 0
- while current do
- current = n_getnext(current)
- length = length + 1
- end
- return length
-end
-
-metatable.__div = function(list,action)
- return action(list) or list -- always a value
-end
-
-metatable.__pow = function(n,multiplier)
- local tail = n
- local head = nil
- if getnext(n) then
- if multiplier == 1 then
- head = n_copy_list(n)
- else
- for i=1,multiplier do
- local h = n_copy_list(n)
- if head then
- local t = n_find_tail(h)
- n_setfield(t,"next",head)
- n_setfield(head,"prev",t)
- end
- head = h
- end
- end
- else
- if multiplier == 1 then
- head = n_copy_node(n)
- else
- for i=2,multiplier do
- local c = n_copy_node(n)
- if head then
- n_setfield(head,"next",c)
- n_setfield(c,"prev",head)
- end
- head = c
- end
- end
- end
- -- todo: tracing
- return head
-end
-
-metatable.__unm = function(head)
- local last = head
- local first = head
- local current = n_getnext(head)
- while current do
- local next = n_getnext(current)
- n_setfield(first,"prev",current)
- n_setfield(current,"next",first)
- first = current
- current = next
- end
- n_setfield(first,"prev",nil)
- n_setfield(last,"next",nil)
- return first
-end
-
--- see node-nut.lua for more info on going nuts
-
-if not gonuts then
-
- local nuts = { }
- nodes.nuts = nuts
-
- local function dummy(f) return f end
-
- nodes.vianuts = dummy
- nodes.vianodes = dummy
-
- for k, v in next, nodes do
- if type(v) == "function" then
- nuts[k] = v
- end
- end
-
-end
-
--- also handy
-
-local tonode = nodes.tonode
-local whatsit_code = nodecodes.whatsit
-local getfields = node.fields
-local sort = table.sort
-local whatsitkeys = { }
-local keys = { whatsit = whatsitkeys }
-local messyhack = table.tohash { -- temporary solution
- nodecodes.attributelist,
- nodecodes.attribute,
- nodecodes.gluespec,
- nodecodes.action,
-}
-
-table.setmetatableindex(keys,function(t,k)
- local v = getfields(k)
- if messyhack[k] then
- for i=1,#v do
- if v[i] == "subtype" then
- remove(v,i)
- break
- end
- end
- end
- if v[ 0] then v[#v+1] = "next" v[ 0] = nil end
- if v[-1] then v[#v+1] = "prev" v[-1] = nil end
- sort(v)
- t[k] = v
- return v
-end)
-
-table.setmetatableindex(whatsitkeys,function(t,k)
- local v = getfields(whatsit_code,k)
- if v[ 0] then v[#v+1] = "next" v[ 0] = nil end
- if v[-1] then v[#v+1] = "prev" v[-1] = nil end
- sort(v)
- t[k] = v
- return v
-end)
-
-local function nodefields(n)
- n = tonode(n)
- local id = n.id
- if id == whatsit_code then
- return whatsitkeys[n.subtype]
- else
- return keys[id]
- end
-end
-
-nodes.keys = keys -- [id][subtype]
-nodes.fields = nodefields -- (n)
diff --git a/tex/context/base/node-pro.lua b/tex/context/base/node-pro.lua
index aa6692d7b..60f2d8a72 100644
--- a/tex/context/base/node-pro.lua
+++ b/tex/context/base/node-pro.lua
@@ -66,12 +66,12 @@ processors.tracer = tracer
processors.enabled = true -- this will become a proper state (like trackers)
-function processors.pre_linebreak_filter(head,groupcode) -- ,size,packtype,direction
+function processors.pre_linebreak_filter(head,groupcode,size,packtype,direction)
local first, found = first_glyph(head) -- they really need to be glyphs
if found then
if trace_callbacks then
local before = nodes.count(head,true)
- local head, done = actions(head,groupcode) -- ,size,packtype,direction
+ local head, done = actions(head,groupcode,size,packtype,direction) -- todo : pass first
local after = nodes.count(head,true)
if done then
tracer("pre_linebreak","changed",head,groupcode,before,after,true)
@@ -80,7 +80,7 @@ function processors.pre_linebreak_filter(head,groupcode) -- ,size,packtype,direc
end
return done and head or true
else
- local head, done = actions(head,groupcode) -- ,size,packtype,direction
+ local head, done = actions(head,groupcode,size,packtype,direction) -- todo : pass first
return done and head or true
end
elseif trace_callbacks then
@@ -94,9 +94,6 @@ local enabled = true
function processors.hpack_filter(head,groupcode,size,packtype,direction)
if enabled then
- -- if not head.next and head.id ~= glyph_code then -- happens often but not faster
- -- return true
- -- end
local first, found = first_glyph(head) -- they really need to be glyphs
if found then
if trace_callbacks then
diff --git a/tex/context/base/node-ref.lua b/tex/context/base/node-ref.lua
index aa864fb1c..09e066434 100644
--- a/tex/context/base/node-ref.lua
+++ b/tex/context/base/node-ref.lua
@@ -16,60 +16,61 @@ if not modules then modules = { } end modules ['node-ref'] = {
-- is grouplevel still used?
-local attributes, nodes, node = attributes, nodes, node
+local format = string.format
+
+local allocate, mark = utilities.storage.allocate, utilities.storage.mark
-local allocate = utilities.storage.allocate, utilities.storage.mark
-local mark = utilities.storage.allocate, utilities.storage.mark
+local cleanupreferences, cleanupdestinations = false, true
+local attributes, nodes, node = attributes, nodes, node
-local nodeinjections = backends.nodeinjections
-local codeinjections = backends.codeinjections
+local nodeinjections = backends.nodeinjections
+local codeinjections = backends.codeinjections
-local cleanupreferences = false
-local cleanupdestinations = true
+local transparencies = attributes.transparencies
+local colors = attributes.colors
+local references = structures.references
+local tasks = nodes.tasks
-local transparencies = attributes.transparencies
-local colors = attributes.colors
-local references = structures.references
-local tasks = nodes.tasks
+local hpack_list = node.hpack
+local list_dimensions = node.dimensions
-local hpack_list = node.hpack
-local list_dimensions = node.dimensions
+-- current.glue_set current.glue_sign
-local trace_backend = false trackers.register("nodes.backend", function(v) trace_backend = v end)
-local trace_references = false trackers.register("nodes.references", function(v) trace_references = v end)
-local trace_destinations = false trackers.register("nodes.destinations", function(v) trace_destinations = v end)
+local trace_backend = false trackers.register("nodes.backend", function(v) trace_backend = v end)
+local trace_references = false trackers.register("nodes.references", function(v) trace_references = v end)
+local trace_destinations = false trackers.register("nodes.destinations", function(v) trace_destinations = v end)
-local report_reference = logs.reporter("backend","references")
-local report_destination = logs.reporter("backend","destinations")
-local report_area = logs.reporter("backend","areas")
+local report_reference = logs.reporter("backend","references")
+local report_destination = logs.reporter("backend","destinations")
+local report_area = logs.reporter("backend","areas")
-local nodecodes = nodes.nodecodes
-local skipcodes = nodes.skipcodes
-local whatcodes = nodes.whatcodes
-local listcodes = nodes.listcodes
+local nodecodes = nodes.nodecodes
+local skipcodes = nodes.skipcodes
+local whatcodes = nodes.whatcodes
+local listcodes = nodes.listcodes
-local hlist_code = nodecodes.hlist
-local vlist_code = nodecodes.vlist
-local glue_code = nodecodes.glue
-local whatsit_code = nodecodes.whatsit
+local hlist_code = nodecodes.hlist
+local vlist_code = nodecodes.vlist
+local glue_code = nodecodes.glue
+local whatsit_code = nodecodes.whatsit
-local leftskip_code = skipcodes.leftskip
-local rightskip_code = skipcodes.rightskip
-local parfillskip_code = skipcodes.parfillskip
+local leftskip_code = skipcodes.leftskip
+local rightskip_code = skipcodes.rightskip
+local parfillskip_code = skipcodes.parfillskip
-local localpar_code = whatcodes.localpar
-local dir_code = whatcodes.dir
+local localpar_code = whatcodes.localpar
+local dir_code = whatcodes.dir
-local line_code = listcodes.line
+local line_code = listcodes.line
-local nodepool = nodes.pool
+local nodepool = nodes.pool
-local new_kern = nodepool.kern
+local new_kern = nodepool.kern
-local traverse = node.traverse
-local find_node_tail = node.tail or node.slide
-local tosequence = nodes.tosequence
+local traverse = node.traverse
+local find_node_tail = node.tail or node.slide
+local tosequence = nodes.tosequence
-- local function dimensions(parent,start,stop)
-- stop = stop and stop.next
@@ -361,19 +362,20 @@ local function colorize(width,height,depth,n,reference,what)
end
end
--- references:
+local nodepool = nodes.pool
-local nodepool = nodes.pool
-local new_kern = nodepool.kern
+local new_kern = nodepool.kern
-local texsetattribute = tex.setattribute
-local texsetcount = tex.setcount
+local texattribute = tex.attribute
+local texcount = tex.count
-local stack = { }
-local done = { }
-local attribute = attributes.private('reference')
-local nofreferences = 0
-local topofstack = 0
+-- references:
+
+local stack = { }
+local done = { }
+local attribute = attributes.private('reference')
+local nofreferences = 0
+local topofstack = 0
nodes.references = {
attribute = attribute,
@@ -388,8 +390,8 @@ local function setreference(h,d,r)
-- the preroll permits us to determine samepage (but delayed also has some advantages)
-- so some part of the backend work is already done here
stack[topofstack] = { r, h, d, codeinjections.prerollreference(r) }
- -- texsetattribute(attribute,topofstack) -- todo -> at tex end
- texsetcount("lastreferenceattribute",topofstack)
+ -- texattribute[attribute] = topofstack -- todo -> at tex end
+ texcount.lastreferenceattribute = topofstack
end
function references.get(n) -- not public so functionality can change
@@ -498,16 +500,13 @@ local function makedestination(width,height,depth,reference)
nofdestinations = nofdestinations + 1
for n=1,#name do
local annot = nodeinjections.destination(width,height,depth,name[n],view)
- if annot then
- -- probably duplicate
- if not result then
- result = annot
- else
- current.next = annot
- annot.prev = current
- end
- current = find_node_tail(annot)
+ if not result then
+ result = annot
+ else
+ current.next = annot
+ annot.prev = current
end
+ current = find_node_tail(annot)
end
if result then
-- some internal error
@@ -541,7 +540,7 @@ function references.inject(prefix,reference,h,d,highlight,newwindow,layer) -- to
-- unknown ref, just don't set it and issue an error
else
-- check
- set.highlight, set.newwindow, set.layer = highlight, newwindow, layer
+ set.highlight, set.newwindow,set.layer = highlight, newwindow, layer
setreference(h,d,set) -- sets attribute / todo: for set[*].error
end
end
@@ -574,7 +573,7 @@ end
statistics.register("interactive elements", function()
if nofreferences > 0 or nofdestinations > 0 then
- return string.format("%s references, %s destinations",nofreferences,nofdestinations)
+ return format("%s references, %s destinations",nofreferences,nofdestinations)
else
return nil
end
diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua
index ca9d67f91..768aac404 100644
--- a/tex/context/base/node-res.lua
+++ b/tex/context/base/node-res.lua
@@ -35,9 +35,6 @@ local glyph_code = nodecodes.glyph
local allocate = utilities.storage.allocate
-local texgetbox = tex.getbox
-local texgetcount = tex.getcount
-
local reserved, nofreserved = { }, 0
local function register_node(n)
@@ -60,10 +57,11 @@ function pool.cleanup(nofboxes) -- todo
-- end
end
if nofboxes then
+ local tb = tex.box
for i=0,nofboxes do
- local l = texgetbox(i)
+ local l = tb[i]
if l then
- free_node(l) -- also list ?
+ free_node(tb[i])
nl = nl + 1
end
end
@@ -295,38 +293,12 @@ function pool.noad()
return copy_node(noad)
end
-function pool.hlist(list,width,height,depth)
- local n = copy_node(hlist)
- if list then
- n.list = list
- end
- if width then
- n.width = width
- end
- if height then
- n.height = height
- end
- if depth then
- n.depth = depth
- end
- return n
+function pool.hlist()
+ return copy_node(hlist)
end
-function pool.vlist(list,width,height,depth)
- local n = copy_node(vlist)
- if list then
- n.list = list
- end
- if width then
- n.width = width
- end
- if height then
- n.height = height
- end
- if depth then
- n.depth = depth
- end
- return n
+function pool.vlist()
+ return copy_node(vlist)
end
--[[
@@ -424,7 +396,7 @@ function pool.special(str)
end
statistics.register("cleaned up reserved nodes", function()
- return format("%s nodes, %s lists of %s", pool.cleanup(texgetcount("c_syst_last_allocated_box")))
+ return format("%s nodes, %s lists of %s", pool.cleanup(tex.count["c_syst_last_allocated_box"]))
end) -- \topofboxstack
statistics.register("node memory usage", function() -- comes after cleanup !
diff --git a/tex/context/base/node-rul.lua b/tex/context/base/node-rul.lua
index 96d6bdf41..953beb186 100644
--- a/tex/context/base/node-rul.lua
+++ b/tex/context/base/node-rul.lua
@@ -85,9 +85,6 @@ local variables = interfaces.variables
local dimenfactor = fonts.helpers.dimenfactor
local splitdimen = number.splitdimen
-local v_yes = variables.yes
-local v_foreground = variables.foreground
-
local nodecodes = nodes.nodecodes
local skipcodes = nodes.skipcodes
local whatcodes = nodes.whatcodes
@@ -153,7 +150,7 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
else
-- possible extensions: when in same class then keep spanning
local newlevel, newclass = floor(aa/1000), aa%1000
- -- strip = not continue or level == 1 -- 0
+--~ strip = not continue or level == 1 -- 0
if f then
if class == newclass then -- and newlevel > level then
head, done = flush(head,f,l,d,level,parent,false), true
@@ -164,7 +161,7 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
f, l, a = n, n, aa
level, class = newlevel, newclass
d = data[class]
- continue = d.continue == v_yes
+ continue = d.continue == variables.yes
end
else
if f then
@@ -172,16 +169,8 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
end
f, l, a = nil, nil, nil
end
--- elseif f and (id == disc_code or (id == kern_code and n.subtype == kerning_code)) then
--- l = n
- elseif id == disc_code then
- if f then
- l = n
- end
- elseif id == kern_code and n.subtype == kerning_code then
- if f then
- l = n
- end
+ elseif f and (id == disc_code or (id == kern_code and n.subtype == kerning_code)) then
+ l = n
elseif id == hlist_code or id == vlist_code then
if f then
head, done = flush(head,f,l,d,level,parent,strip), true
@@ -199,12 +188,13 @@ local function processwords(attribute,data,flush,head,parent) -- we have hlistdi
if continue then
if id == penalty_code then
l = n
- -- elseif id == kern_code then
- -- l = n
+ elseif id == kern_code then
+ l = n
elseif id == glue_code then
-- catch \underbar{a} \underbar{a} (subtype test is needed)
local subtype = n.subtype
- if n[attribute] and (subtype == userskip_code or subtype == spaceskip_code or subtype == xspaceskip_code) then
+ if continue and n[attribute] and
+ (subtype == userskip_code or subtype == spaceskip_code or subskip == xspaceskip_code) then
l = n
else
head, done = flush(head,f,l,d,level,parent,strip), true
@@ -271,9 +261,9 @@ local function flush_ruled(head,f,l,d,level,parent,strip) -- not that fast but a
local colorspace = ma > 0 and ma or f[a_colorspace] or 1
local color = ca > 0 and ca or f[a_color]
local transparency = ta > 0 and ta or f[a_transparency]
- local foreground = order == v_foreground
+ local foreground = order == variables.foreground
- local e = dimenfactor(unit,f.font) -- what if no glyph node
+ local e = dimenfactor(unit,fontdata[f.font]) -- what if no glyph node
local rt = tonumber(rulethickness)
if rt then
diff --git a/tex/context/base/node-rul.mkiv b/tex/context/base/node-rul.mkiv
index 2d2e61134..640cc54fe 100644
--- a/tex/context/base/node-rul.mkiv
+++ b/tex/context/base/node-rul.mkiv
@@ -185,14 +185,9 @@
% \definebar[touchbar] [\c!method=0,\c!dy=-0.4,\c!offset=-0.0]
% \definebar[touchbars] [touchbar] [\c!continue=\v!yes]
-\let\normalmathoverbar \overbar
-\let\normalmathunderbar \underbar
-\let\normalmathoverstrike \overstrike
-\let\normalmathunderstrike\understrike
-
-\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes]
-\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]
+\definebar[\v!underbar] [\c!method=1,\c!dy=-0.4,\c!offset=-0.3,\c!continue=\v!yes]
+\definebar[\v!overbar] [\c!method=1,\c!dy=0.4,\c!offset=1.8,\c!continue=\v!yes]
\definebar
[\v!understrike]
@@ -203,41 +198,16 @@
\c!order=\v!background,
\c!color=lightgray]
-\definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no]
-\definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no]
\definebar[\v!overstrikes] [\v!overstrike] [\c!continue=\v!no]
+\definebar[\v!underbars] [\v!underbar] [\c!continue=\v!no]
+\definebar[\v!overbars] [\v!overbar] [\c!continue=\v!no]
\definebar[\v!understrikes][\v!understrike][\c!continue=\v!no]
% we want these always so ...
-\ifdefined\normalmathunderbar
- \expandafter\let\expandafter\normaltextunderbar\csname\v!underbar\endcsname
- \unexpanded\def\underbar{\mathortext\normalmathunderbar\normaltextunderbar}
-\else
- \expandafter\let\expandafter\underbar\csname\v!underbar\endcsname
-\fi
-
-\ifdefined\normalmathoverbar
- \expandafter\let\expandafter\normaltextoverbar\csname\v!overbar\endcsname
- \unexpanded\def\overbar{\mathortext\normalmathoverbar\normaltextoverbar}
-\else
- \expandafter\let\expandafter\overbar\csname\v!overbar\endcsname
-\fi
-
-\ifdefined\normalmathunderstrike
- \expandafter\let\expandafter\normaltextunderstrike\csname\v!understrike\endcsname
- \unexpanded\def\understrike{\mathortext\normalmathunderstrike\normaltextunderstrike}
-\else
- \expandafter\let\expandafter\understrike\csname\v!understrike\endcsname
-\fi
-
-\ifdefined\normalmathoverstrike
- \expandafter\let\expandafter\normaltextoverstrike\csname\v!overstrike\endcsname
- \unexpanded\def\overstrike{\mathortext\normalmathoverstrike \normaltextoverstrike}
-\else
- \expandafter\let\expandafter\overstrike\csname\v!overstrike\endcsname
-\fi
-
+\expandafter\let\expandafter\overstrike \csname\v!overstrike \endcsname
+\expandafter\let\expandafter\underbar \csname\v!underbar \endcsname
+\expandafter\let\expandafter\overbar \csname\v!overbar \endcsname
\expandafter\let\expandafter\overstrikes\csname\v!overstrikes\endcsname
\expandafter\let\expandafter\underbars \csname\v!underbars \endcsname
\expandafter\let\expandafter\overbars \csname\v!overbars \endcsname
diff --git a/tex/context/base/node-ser.lua b/tex/context/base/node-ser.lua
index d7593cec7..b0a6e9952 100644
--- a/tex/context/base/node-ser.lua
+++ b/tex/context/base/node-ser.lua
@@ -9,37 +9,24 @@ if not modules then modules = { } end modules ['node-ser'] = {
-- beware, some field names will change in a next releases
-- of luatex; this is pretty old code that needs an overhaul
-local type = type
+local type, format, rep = type, string.format, string.rep
local concat, tohash, sortedkeys, printtable = table.concat, table.tohash, table.sortedkeys, table.print
-local formatters, format, rep = string.formatters, string.format, string.rep
local allocate = utilities.storage.allocate
-local context = context
-local nodes = nodes
-local node = node
+local nodes, node = nodes, node
-local traverse = nodes.traverse
-local is_node = nodes.is_node
+local traverse = node.traverse
+local is_node = node.is_node
local nodecodes = nodes.nodecodes
-local subtcodes = nodes.codes
local noadcodes = nodes.noadcodes
-local getfields = nodes.fields
-
-local tonode = nodes.tonode
+local nodefields = nodes.fields
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
------ utfchar = utf.char
-local f_char = formatters["%U"]
------ fontchars = { } table.setmetatableindex(fontchars,function(t,k) fontchars = fonts.hashes.characters return fontchars[k] end)
-
------ f_char = utilities.strings.chkuni -- formatters["%!chkuni!"]
-
local expand = allocate ( tohash {
- -- text:
"list", -- list_ptr & ins_ptr & adjust_ptr
"pre", --
"post", --
@@ -55,23 +42,6 @@ local expand = allocate ( tohash {
"action", -- action_ptr
"value", -- user_defined nodes with subtype 'a' en 'n'
"head",
- -- math:
- "nucleus",
- "sup",
- "sub",
- "list",
- "num",
- "denom",
- "left",
- "right",
- "display",
- "text",
- "script",
- "scriptscript",
- "delim",
- "degree",
- "accent",
- "bot_accent",
} )
-- page_insert: "height", "last_ins_ptr", "best_ins_ptr"
@@ -102,9 +72,8 @@ nodes.ignorablefields = ignore
-- not ok yet:
-local function astable(n,sparse) -- not yet ok, might get obsolete anyway
- n = tonode(n)
- local f, t = getfields(n), { }
+local function astable(n,sparse) -- not yet ok
+ local f, t = nodefields(n), { }
for i=1,#f do
local v = f[i]
local d = n[v]
@@ -132,9 +101,10 @@ setinspector(function(v) if is_node(v) then printtable(astable(v),tostring(v)) r
-- under construction:
-local function totable(n,flat,verbose,noattributes) -- nicest: n,true,true,true
+local function totable(n,flat,verbose,noattributes)
+ -- todo: no local function
local function to_table(n,flat,verbose,noattributes) -- no need to pass
- local f = getfields(n)
+ local f = nodefields(n)
local tt = { }
for k=1,#f do
local v = f[k]
@@ -148,7 +118,7 @@ local function totable(n,flat,verbose,noattributes) -- nicest: n,true,true,true
if type(nv) == "number" or type(nv) == "string" then
tt[v] = nv
else
- tt[v] = totable(nv,flat,verbose,noattributes)
+ tt[v] = totable(nv,flat,verbose)
end
elseif type(nv) == "table" then
tt[v] = nv -- totable(nv,flat,verbose) -- data
@@ -158,27 +128,7 @@ local function totable(n,flat,verbose,noattributes) -- nicest: n,true,true,true
end
end
if verbose then
- local subtype = tt.subtype
- local id = tt.id
- local nodename = nodecodes[id]
- tt.id = nodename
- local subtypes = subtcodes[nodename]
- if subtypes then
- tt.subtype = subtypes[subtype]
- elseif subtype == 0 then
- tt.subtype = nil
- else
- -- we need a table
- end
- if tt.char then
- tt.char = f_char(tt.char)
- end
- if tt.small_char then
- tt.small_char = f_char(tt.small_char)
- end
- if tt.large_char then
- tt.large_char = f_char(tt.large_char)
- end
+ tt.type = nodecodes[tt.id]
end
return tt
end
@@ -187,18 +137,14 @@ local function totable(n,flat,verbose,noattributes) -- nicest: n,true,true,true
local t, tn = { }, 0
while n do
tn = tn + 1
- local nt = to_table(n,flat,verbose,noattributes)
- t[tn] = nt
- nt.next = nil
- nt.prev = nil
+ t[tn] = to_table(n,flat,verbose,noattributes)
n = n.next
end
return t
else
- local t = to_table(n,flat,verbose,noattributes)
- local n = n.next
- if n then
- t.next = totable(n,flat,verbose,noattributes)
+ local t = to_table(n)
+ if n.next then
+ t.next = totable(n.next,flat,verbose,noattributes)
end
return t
end
@@ -207,8 +153,7 @@ local function totable(n,flat,verbose,noattributes) -- nicest: n,true,true,true
end
end
-nodes.totable = function(n,...) return totable(tonode(n),...) end
-nodes.totree = function(n) return totable(tonode(n),true,true,true) end -- no attributes, todo: attributes in k,v list
+nodes.totable = totable
local function key(k)
return ((type(k) == "number") and "["..k.."]") or k
@@ -216,7 +161,7 @@ end
-- not ok yet; this will become a module
--- todo: adapt to nodecodes etc .. use formatters
+-- todo: adapt to nodecodes etc
local function serialize(root,name,handle,depth,m,noattributes)
handle = handle or print
@@ -241,12 +186,12 @@ local function serialize(root,name,handle,depth,m,noattributes)
if root then
local fld
if root.id then
- fld = getfields(root) -- we can cache these (todo)
+ fld = nodefields(root) -- we can cache these (todo)
else
fld = sortedkeys(root)
end
if type(root) == 'table' and root['type'] then -- userdata or table
- handle(format("%s type=%q,",depth,root['type']))
+ handle(format("%s %s=%q,",depth,'type',root['type']))
end
for f=1,#fld do
local k = fld[f]
@@ -296,7 +241,7 @@ function nodes.serialize(root,name,noattributes)
n = n + 1
t[n] = s
end
- serialize(tonode(root),name,flush,nil,0,noattributes)
+ serialize(root,name,flush,nil,0,noattributes)
return concat(t,"\n")
end
@@ -313,7 +258,6 @@ function nodes.visualizebox(...) -- to be checked .. will move to module anyway
end
function nodes.list(head,n) -- name might change to nodes.type -- to be checked .. will move to module anyway
- head = tonode(head)
if not n then
context.starttyping(true)
end
@@ -331,7 +275,6 @@ function nodes.list(head,n) -- name might change to nodes.type -- to be checked
end
function nodes.print(head,n)
- head = tonode(head)
while head do
local id = head.id
logs.writer(string.formatters["%w%S"],n or 0,head)
diff --git a/tex/context/base/node-shp.lua b/tex/context/base/node-shp.lua
index 6ebfd767f..8f7a411a7 100644
--- a/tex/context/base/node-shp.lua
+++ b/tex/context/base/node-shp.lua
@@ -14,7 +14,6 @@ local concat, sortedpairs = table.concat, table.sortedpairs
local setmetatableindex = table.setmetatableindex
local nodecodes = nodes.nodecodes
-local whatsitcodes = nodes.whatsitcodes
local tasks = nodes.tasks
local handlers = nodes.handlers
@@ -24,52 +23,28 @@ local disc_code = nodecodes.disc
local mark_code = nodecodes.mark
local kern_code = nodecodes.kern
local glue_code = nodecodes.glue
-local whatsit_code = nodecodes.whatsit
-local texgetbox = tex.getbox
+local texbox = tex.box
local free_node = node.free
local remove_node = node.remove
local traverse_nodes = node.traverse
-local removables = {
- [whatsitcodes.open] = true,
- [whatsitcodes.close] = true,
- [whatsitcodes.write] = true,
- [whatsitcodes.pdfdest] = true,
- [whatsitcodes.pdfsavepos] = true,
- [whatsitcodes.latelua] = true,
-}
-
-local function cleanup_redundant(head)
+local function cleanup(head) -- rough
local start = head
while start do
local id = start.id
- if id == disc_code then
- head, start = remove_node(head,start,true)
- -- elseif id == glue_code then
- -- if start.writable then
- -- start = start.next
- -- elseif some_complex_check_on_glue_spec then
- -- head, start = remove_node(head,start,true)
- -- else
- -- start = start.next
- -- end
- elseif id == kern_code then
- if start.kern == 0 then
- head, start = remove_node(head,start,true)
- else
- start = start.next
- end
- elseif id == mark_code then
- head, start = remove_node(head,start,true)
+ if id == disc_code or (id == glue_code and not start.writable) or (id == kern_code and start.kern == 0) or id == mark_code then
+ head, start, tmp = remove_node(head,start)
+ free_node(tmp)
elseif id == hlist_code or id == vlist_code then
local sl = start.list
if sl then
- start.list = cleanup_redundant(sl)
+ start.list = cleanup(sl)
start = start.next
else
- head, start = remove_node(head,start,true)
+ head, start, tmp = remove_node(head,start)
+ free_node(tmp)
end
else
start = start.next
@@ -78,56 +53,27 @@ local function cleanup_redundant(head)
return head
end
-local function cleanup_flushed(head) -- rough
- local start = head
- while start do
- local id = start.id
- if id == whatsit_code and removables[start.subtype] then
- head, start = remove_node(head,start,true)
- elseif id == hlist_code or id == vlist_code then
- local sl = start.list
- if sl then
- start.list = cleanup_flushed(sl)
- start = start.next
- else
- head, start = remove_node(head,start,true)
- end
- else
- start = start.next
- end
- end
- return head
-end
+directives.register("backend.cleanup", function()
+ tasks.enableaction("shipouts","nodes.handlers.cleanuppage")
+end)
function handlers.cleanuppage(head)
-- about 10% of the nodes make no sense for the backend
- return cleanup_redundant(head), true
+ return cleanup(head), true
end
-function handlers.cleanupbox(head)
- return cleanup_flushed(head), true
-end
-
-directives.register("backend.cleanup", function()
- tasks.enableaction("shipouts","nodes.handlers.cleanuppage")
-end)
-
local actions = tasks.actions("shipouts") -- no extra arguments
function handlers.finalize(head) -- problem, attr loaded before node, todo ...
return actions(head)
end
-function commands.cleanupbox(n)
- cleanup_flushed(texgetbox(n))
-end
-
-- handlers.finalize = actions
-- interface
function commands.finalizebox(n)
- actions(texgetbox(n))
+ actions(texbox[n])
end
-- just in case we want to optimize lookups:
@@ -183,8 +129,8 @@ trackers.register("nodes.frequencies",function(v)
if type(v) == "string" then
frequencies.filename = v
end
- handlers.frequencies_shipouts_before = register("shipouts", "begin")
- handlers.frequencies_shipouts_after = register("shipouts", "end")
+ handlers.frequencies_shipouts_before = register("shipouts", "begin")
+ handlers.frequencies_shipouts_after = register("shipouts", "end")
handlers.frequencies_processors_before = register("processors", "begin")
handlers.frequencies_processors_after = register("processors", "end")
tasks.prependaction("shipouts", "before", "nodes.handlers.frequencies_shipouts_before")
diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua
index 9fe979e93..916b2143d 100644
--- a/tex/context/base/node-tra.lua
+++ b/tex/context/base/node-tra.lua
@@ -18,9 +18,9 @@ local clock = os.gettimeofday or os.clock -- should go in environment
local report_nodes = logs.reporter("nodes","tracing")
-local nodes, node, context = nodes, node, context
+nodes = nodes or { }
-local texgetattribute = tex.getattribute
+local nodes, node, context = nodes, node, context
local tracers = nodes.tracers or { }
nodes.tracers = tracers
@@ -51,13 +51,12 @@ local glue_code = nodecodes.glue
local kern_code = nodecodes.kern
local rule_code = nodecodes.rule
local whatsit_code = nodecodes.whatsit
-local gluespec_code = nodecodes.gluespec
+local spec_code = nodecodes.glue_spec
local localpar_code = whatcodes.localpar
local dir_code = whatcodes.dir
local nodepool = nodes.pool
-local new_rule = nodepool.rule
local dimenfactors = number.dimenfactors
local formatters = string.formatters
@@ -258,19 +257,16 @@ local function listtoutf(h,joiner,textonly,last)
while h do
local id = h.id
if id == glyph_code then -- always true
- local c = h.char
- w[#w+1] = c >= 0 and utfchar(c) or formatters["<%i>"](c)
+ w[#w+1] = utfchar(h.char)
if joiner then
w[#w+1] = joiner
end
elseif id == disc_code then
- local pre = h.pre
- local pos = h.post
- local rep = h.replace
+ local pre, rep, pos = h.pre, h.replace, h.post
w[#w+1] = formatters["[%s|%s|%s]"] (
pre and listtoutf(pre,joiner,textonly) or "",
- pos and listtoutf(pos,joiner,textonly) or "",
- rep and listtoutf(rep,joiner,textonly) or ""
+ rep and listtoutf(rep,joiner,textonly) or "",
+ mid and listtoutf(mid,joiner,textonly) or ""
)
elseif textonly then
if id == glue_code and h.spec and h.spec.width > 0 then
@@ -346,7 +342,7 @@ local function numbertodimen(d,unit,fmt,strip)
local str = formatters[fmt](d*dimenfactors[unit],unit)
return strip and lpegmatch(stripper,str) or str
end
- local id = d.id
+ local id = node.id
if id == kern_code then
local str = formatters[fmt](d.width*dimenfactors[unit],unit)
return strip and lpegmatch(stripper,str) or str
@@ -354,7 +350,7 @@ local function numbertodimen(d,unit,fmt,strip)
if id == glue_code then
d = d.spec
end
- if not d or not d.id == gluespec_code then
+ if not d or not d.id == spec_code then
local str = formatters[fmt](0,unit)
return strip and lpegmatch(stripper,str) or str
end
@@ -526,63 +522,8 @@ end
-- for the moment here
-local visualizers = nodes.visualizers or { }
-nodes.visualizers = visualizers
+nodes.visualizers = { }
-function visualizers.handler(head)
+function nodes.visualizers.handler(head)
return head, false
end
-
--- we could cache attribute lists and set attr (copy will increment count) .. todo ..
--- although tracers are used seldom
-
-local function setproperties(n,c,s)
- local mm = texgetattribute(a_colormodel)
- n[a_colormodel] = mm > 0 and mm or 1
- n[a_color] = m_color[c]
- n[a_transparency] = m_transparency[c]
- return n
-end
-
-tracers.setproperties = setproperties
-
-function tracers.setlistv(n,c,s)
- local f = n
- local mc = m_color[c]
- local mt = m_transparency[c]
- local mm = texgetattribute(a_colormodel)
- if mm <= 0 then
- mm = 1
- end
- while n do
- n[a_colormodel] = mm
- n[a_color] = mc
- n[a_transparency] = mt
- n = n.next
- end
- return f
-end
-
-function tracers.resetproperties(n)
- n[a_color] = unsetvalue
- n[a_transparency] = unsetvalue
- return n
-end
-
-function tracers.rule(w,h,d,c,s) -- so some day we can consider using literals (speedup)
- return setproperties(new_rule(w,h,d),c,s)
-end
-
--- only nodes
-
-local nodestracerpool = { }
-
-tracers.pool = {
- nodes = nodestracerpool,
-}
-
-function nodestracerpool.rule(w,h,d,c,s) -- so some day we can consider using literals (speedup)
- return setproperties(new_rule(w,h,d),c,s)
-end
-
-tracers.rule = nodestracerpool.rule -- for a while
diff --git a/tex/context/base/node-tsk.lua b/tex/context/base/node-tsk.lua
index dfa570b24..596ac765a 100644
--- a/tex/context/base/node-tsk.lua
+++ b/tex/context/base/node-tsk.lua
@@ -18,11 +18,10 @@ local report_tasks = logs.reporter("tasks")
local allocate = utilities.storage.allocate
-local context = context
local nodes = nodes
-local tasks = nodes.tasks or { }
-nodes.tasks = tasks
+nodes.tasks = nodes.tasks or { }
+local tasks = nodes.tasks
local tasksdata = { } -- no longer public
@@ -117,14 +116,6 @@ function tasks.disableaction(name,action)
end
end
-function tasks.setaction(name,action,value)
- if value then
- tasks.enableaction(name,action)
- else
- tasks.disableaction(name,action)
- end
-end
-
function tasks.enablegroup(name,group)
local data = validgroup(name,"enable group")
if data then
@@ -326,8 +317,7 @@ end
tasks.new {
name = "processors",
- arguments = 5, -- often only the first is used, and the last three are only passed in hpack filter
--- arguments = 2,
+ arguments = 4,
processor = nodeprocessor,
sequence = {
"before", -- for users
diff --git a/tex/context/base/node-typ.lua b/tex/context/base/node-typ.lua
index 4a2ef8d49..6e1a31643 100644
--- a/tex/context/base/node-typ.lua
+++ b/tex/context/base/node-typ.lua
@@ -6,23 +6,21 @@ if not modules then modules = { } end modules ['node-typ'] = {
license = "see context related readme files"
}
--- code has been moved to blob-ini.lua
+local utfvalues = utf.values
-local typesetters = nodes.typesetters or { }
-nodes.typesetters = typesetters
+local currentfont = font.current
+local fontparameters = fonts.hashes.parameters
-local hpack_node_list = nodes.hpack
-local vpack_node_list = nodes.vpack
-local fast_hpack_list = nodes.fasthpack
+local hpack = node.hpack
+local vpack = node.vpack
+local fast_hpack = nodes.fasthpack
-local nodepool = nodes.pool
-local new_glyph = nodepool.glyph
-local new_glue = nodepool.glue
+local nodepool = nodes.pool
-local utfvalues = utf.values
+local newglyph = nodepool.glyph
+local newglue = nodepool.glue
-local currentfont = font.current
-local fontparameters = fonts.hashes.parameters
+typesetters = typesetters or { }
local function tonodes(str,fontid,spacing) -- quick and dirty
local head, prev = nil, nil
@@ -41,11 +39,11 @@ local function tonodes(str,fontid,spacing) -- quick and dirty
local next
if c == 32 then
if not spacedone then
- next = new_glue(s,p,m)
+ next = newglue(s,p,m)
spacedone = true
end
else
- next = new_glyph(fontid or 1,c)
+ next = newglyph(fontid or 1,c)
spacedone = false
end
if not next then
@@ -61,33 +59,21 @@ local function tonodes(str,fontid,spacing) -- quick and dirty
return head
end
-local function tohpack(str,fontid,spacing)
- return hpack_node_list(tonodes(str,fontid,spacing),"exactly")
+typesetters.tonodes = tonodes
+
+function typesetters.hpack(str,fontid,spacing)
+ return hpack(tonodes(str,fontid,spacing),"exactly")
end
-local function tohpackfast(str,fontid,spacing)
- return fast_hpack_list(tonodes(str,fontid,spacing),"exactly")
+function typesetters.fast_hpack(str,fontid,spacing)
+ return fast_hpack(tonodes(str,fontid,spacing),"exactly")
end
-local function tovpack(str,fontid,spacing)
+function typesetters.vpack(str,fontid,spacing)
-- vpack is just a hack, and a proper implentation is on the agenda
-- as it needs more info etc than currently available
- return vpack_node_list(tonodes(str,fontid,spacing))
+ return vpack(tonodes(str,fontid,spacing))
end
-local tovpackfast = tovpack
-
-typesetters.tonodes = tonodes
-typesetters.tohpack = tohpack
-typesetters.tohpackfast = tohpackfast
-typesetters.tovpack = tovpack
-typesetters.tovpackfast = tovpackfast
-
-typesetters.hpack = tohpack
-typesetters.fast_hpack = tohpackfast
-typesetters.vpack = tovpack
-
--- node.write(nodes.typestters.hpack("Hello World!"))
--- node.write(nodes.typestters.hpack("Hello World!",1,100*1024*10))
-
-string.tonodes = tonodes -- quite convenient
+--~ node.write(typesetters.hpack("Hello World!"))
+--~ node.write(typesetters.hpack("Hello World!",1,100*1024*10))
diff --git a/tex/context/base/norm-ltx.mkii b/tex/context/base/norm-ltx.mkii
index 9a8f7ba57..cd02cffec 100644
--- a/tex/context/base/norm-ltx.mkii
+++ b/tex/context/base/norm-ltx.mkii
@@ -155,7 +155,7 @@
\let \normallatelua = \latelua
\let \normalluaescapestring = \luaescapestring
\let \normalluastartup = \luastartup
-%let \normalluatexdatestamp = \luatexdatestamp
+\let \normalluatexdatestamp = \luatexdatestamp
\let \normalluatexrevision = \luatexrevision
\let \normalluatexversion = \luatexversion
\let \normalnokerns = \nokerns
diff --git a/tex/context/base/pack-com.mkiv b/tex/context/base/pack-com.mkiv
index 2c28d6b20..6c1363148 100644
--- a/tex/context/base/pack-com.mkiv
+++ b/tex/context/base/pack-com.mkiv
@@ -267,13 +267,10 @@
\edef\p_pack_combinations_alternative{\combinationparameter\c!alternative}%
\to \everydefinecombination
-\def\pack_combinations_pickup
+\def\pack_combinations_pickup % we want to add struts but still ignore an empty box
{\dostarttagged\t!combinationpair\empty
\dostarttagged\t!combinationcontent\empty
- \assumelongusagecs\pack_combinations_pickup_content_indeed}
-
-\def\pack_combinations_pickup_content_indeed
- {\dowithnextboxcs\pack_combinations_pickup_content\hbox}
+ \dowithnextboxcs\pack_combinations_pickup_content\hbox}
\def\pack_combinations_pickup_content % we want to add struts but still ignore an empty box
{\dostoptagged
@@ -282,21 +279,15 @@
\expandnamespacemacro\??combinationalternative\p_pack_combinations_alternative\v!text}
\setvalue{\??combinationalternative\v!text}%
- {\assumelongusagecs\pack_combinations_alternative_text_indeed}
-
-\setvalue{\??combinationalternative\v!label}%
- {\assumelongusagecs\pack_combinations_alternative_label_indeed}
-
-\def\pack_combinations_alternative_text_indeed
{\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
\afterassignment\pack_combinations_caption_first
\let\nexttoken=}
-\def\pack_combinations_alternative_label_indeed
+\setvalue{\??combinationalternative\v!label}%
{\dowithnextboxcs\pack_combinations_pickup_caption\vtop\bgroup
\hsize\wd\b_pack_combinations_content
\ifx\p_align\empty\else\setupalign[\p_align]\fi
- \usecombinationstyleandcolor\c!style\c!color
+ \usecombinationstyleandcolor\c!style\c!color % but label style wins, so independent configuration
\begstrut
\normalexpanded{\strc_labels_command{\v!combination\ifx\currentcombination\empty\else:\currentcombination\fi}}%
\endstrut
@@ -653,7 +644,7 @@
%
\global\setsystemmode{pairedbox}%
\pack_pairedboxes_before
- \assumelongusagecs\pack_pairedboxes_first_pickup}
+ \dogotopar\pack_pairedboxes_first_pickup}
\def\pack_pairedboxes_first_pickup
{\dowithnextboxcs\pack_pairedboxes_first\hbox
@@ -662,7 +653,7 @@
\def\pack_pairedboxes_first
{\pack_pairedboxes_between
- \assumelongusagecs\pack_pairedboxes_second_pickup}
+ \dogotopar\pack_pairedboxes_second_pickup}
\def\pack_pairedboxes_second_pickup
{\dowithnextboxcs\pack_pairedboxes_second\vbox
@@ -791,32 +782,19 @@
\setrigidcolumnhsize\hsize{\pairedboxparameter\c!distance}\p_n
\fi}
-% \def\pack_pairedboxes_between_horizontal
-% {\setlocalhsize
-% \hsize\wd\b_pack_pairedboxes_first % trick
-% \hsize\pairedboxparameter\c!width % can be \hsize
-% \scratchdimen\dimexpr\wd\b_pack_pairedboxes_first+\pairedboxparameter\c!distance\relax
-% \ifdim\dimexpr\hsize+\scratchdimen\relax>\pairedboxparameter\c!maxwidth\relax
-% \hsize\dimexpr\pairedboxparameter\c!maxwidth-\scratchdimen\relax
-% \fi}
-
\def\pack_pairedboxes_between_horizontal
- {\scratchdistance\pairedboxparameter\c!distance
- \scratchwidth\pairedboxparameter\c!maxwidth\relax
- \setlocalhsize
- \hsize\dimexpr\availablehsize-\wd\b_pack_pairedboxes_first-\scratchdistance\relax
- \hsize\pairedboxparameter\c!width\relax % can be \hsize
- \scratchdimen\dimexpr\wd\b_pack_pairedboxes_first+\scratchdistance\relax
- \ifdim\dimexpr\hsize+\scratchdimen\relax>\scratchwidth
- \hsize\dimexpr\scratchwidth-\scratchdimen\relax
+ {\hsize\wd\b_pack_pairedboxes_first % trick
+ \hsize\pairedboxparameter\c!width % can be \hsize
+ \scratchdimen\dimexpr\wd\b_pack_pairedboxes_first+\pairedboxparameter\c!distance\relax
+ \ifdim\dimexpr\hsize+\scratchdimen\relax>\pairedboxparameter\c!maxwidth\relax
+ \hsize\dimexpr\pairedboxparameter\c!maxwidth-\scratchdimen\relax
\fi}
\def\pack_pairedboxes_between_vertical
- {\scratchwidth\pairedboxparameter\c!maxwidth\relax
- \hsize\wd\b_pack_pairedboxes_first
- \hsize\pairedboxparameter\c!width\relax % can be \hsize
- \ifdim\hsize>\scratchwidth\relax
- \hsize\scratchwidth
+ {\hsize\wd\b_pack_pairedboxes_first
+ \hsize\pairedboxparameter\c!width % can be \hsize
+ \ifdim\hsize>\pairedboxparameter\c!maxwidth\relax
+ \hsize\pairedboxparameter\c!maxwidth % can be \hsize
\fi}
\def\pack_pairedboxes_after
@@ -833,7 +811,7 @@
\fi}
\def\pack_pairedboxes_pack_horizontal
- {\dontleavehmode\hbox\bgroup
+ {\hbox\bgroup
\forgetall
\s_pack_pairedboxes_size\ht
\ifdim\ht\b_pack_pairedboxes_first>\ht\b_pack_pairedboxes_second
@@ -854,7 +832,7 @@
\egroup}
\def\pack_pairedboxes_pack_vertical
- {\dontleavehmode\vbox\bgroup
+ {\vbox\bgroup
\forgetall
\s_pack_pairedboxes_size\wd
\ifdim\wd\b_pack_pairedboxes_first>\wd\b_pack_pairedboxes_second
diff --git a/tex/context/base/pack-obj.lua b/tex/context/base/pack-obj.lua
index 70876a346..1e4e0f59e 100644
--- a/tex/context/base/pack-obj.lua
+++ b/tex/context/base/pack-obj.lua
@@ -13,7 +13,8 @@ reusable components.
local commands, context = commands, context
-local allocate = utilities.storage.allocate
+local texcount = tex.count
+local allocate = utilities.storage.allocate
local collected = allocate()
local tobesaved = allocate()
diff --git a/tex/context/base/pack-rul.lua b/tex/context/base/pack-rul.lua
index 909c0c168..a990936e7 100644
--- a/tex/context/base/pack-rul.lua
+++ b/tex/context/base/pack-rul.lua
@@ -10,21 +10,16 @@ if not modules then modules = { } end modules ['pack-rul'] = {
An explanation is given in the history document mk.
--ldx]]--
-local hpack = node.hpack
-local free = node.free
-local copy = node.copy_list
-local traverse_id = node.traverse_id
-local node_dimensions = node.dimensions
+local texsetdimen, texsetcount, texbox = tex.setdimen, tex.setcount, tex.box
+local hpack, free, copy, traverse_id = node.hpack, node.free, node.copy_list, node.traverse_id
+local texdimen, texcount = tex.dimen, tex.count
local hlist_code = nodes.nodecodes.hlist
local box_code = nodes.listcodes.box
-
-local texsetdimen = tex.setdimen
-local texsetcount = tex.setcount
-local texgetbox = tex.getbox
+local node_dimensions = node.dimensions
function commands.doreshapeframedbox(n)
- local box = texgetbox(n)
+ local box = texbox[n]
local noflines = 0
local firstheight = nil
local lastdepth = nil
@@ -81,16 +76,17 @@ function commands.doreshapeframedbox(n)
end
end
end
- texsetcount("global","framednoflines",noflines)
- texsetdimen("global","framedfirstheight",firstheight or 0)
- texsetdimen("global","framedlastdepth",lastdepth or 0)
- texsetdimen("global","framedminwidth",minwidth)
- texsetdimen("global","framedmaxwidth",maxwidth)
- texsetdimen("global","framedaveragewidth",noflines > 0 and totalwidth/noflines or 0)
+ -- print("reshape", noflines, firstheight or 0, lastdepth or 0)
+ texsetcount("global","framednoflines", noflines)
+ texsetdimen("global","framedfirstheight", firstheight or 0)
+ texsetdimen("global","framedlastdepth", lastdepth or 0)
+ texsetdimen("global","framedminwidth", minwidth)
+ texsetdimen("global","framedmaxwidth", maxwidth)
+ texsetdimen("global","framedaveragewidth", noflines > 0 and totalwidth/noflines or 0)
end
function commands.doanalyzeframedbox(n)
- local box = texgetbox(n)
+ local box = texbox[n]
local noflines = 0
local firstheight = nil
local lastdepth = nil
@@ -106,7 +102,8 @@ function commands.doanalyzeframedbox(n)
end
end
end
- texsetcount("global","framednoflines",noflines)
- texsetdimen("global","framedfirstheight",firstheight or 0)
- texsetdimen("global","framedlastdepth",lastdepth or 0)
+ -- print("analyze", noflines, firstheight or 0, lastdepth or 0)
+ texsetcount("global","framednoflines", noflines)
+ texsetdimen("global","framedfirstheight", firstheight or 0)
+ texsetdimen("global","framedlastdepth", lastdepth or 0)
end
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index bff8b4a0f..f2b332b14 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -100,11 +100,11 @@
\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
+ \noexpand\??framed}} % if needed we can have a variant
\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#9:##1\endcsname#9:##1\else\s!empty\fi}% root
\unexpanded\def#8%
{\bgroup
\bgroup
@@ -113,15 +113,7 @@
\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}}
+ \pack_framed_process_indeed}}
\unexpanded\def\installframedcommandhandler#1#2#3%
{\installcommandhandler{#1}{#2}{#3}%
@@ -888,8 +880,11 @@
%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
+\unexpanded\def\localbackgroundframed#1#2#3% namespace component box
+ {\bgroup
+ \edef\currentframed{#1}%
+ \pack_framed_initialize
+ \setbox\b_framed_normal\box#3%
\edef\p_framed_region{\framedparameter\c!region}%
\ifx\p_framed_region\v!yes % maybe later named
\pack_framed_add_region
@@ -912,18 +907,12 @@
\else
\p_framed_backgroundoffset
\fi
- \edef\p_framed_component{#1}%
+ \edef\p_framed_component{#2}%
\pack_framed_add_background
\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:
@@ -1649,41 +1638,27 @@
% \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
-% \scratchcounter\p_framed_orientation % weird .. why
-% \divide\scratchcounter\plustwo
-% \ifodd\scratchcounter
-% \let\pack_framed_stop_orientation\pack_framed_stop_orientation_odd
-% \else
-% \let\pack_framed_stop_orientation\pack_framed_stop_orientation_even
-% \fi
-% \fi}
-%
-% \def\pack_framed_stop_orientation_odd
-% {\swapmacros\framedwidth\framedheight
-% \swapmacros\localwidth\localheight
-% \swapdimens\d_framed_height\d_framed_width
-% \pack_framed_stop_orientation_even}
-%
-% \def\pack_framed_stop_orientation_even
-% {\setbox\b_framed_normal\hbox{\dorotatebox\p_framed_orientation\hbox{\box\b_framed_normal}}%
-% \d_framed_height\ht\b_framed_normal
-% \d_framed_width \wd\b_framed_normal}
-
\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
+ \scratchcounter\p_framed_orientation % weird .. why
+ \divide\scratchcounter\plustwo
+ \ifodd\scratchcounter
+ \let\pack_framed_stop_orientation\pack_framed_stop_orientation_odd
+ \else
+ \let\pack_framed_stop_orientation\pack_framed_stop_orientation_even
+ \fi
\fi}
-\def\pack_framed_stop_orientation_indeed
- {\setbox\b_framed_normal\hbox{\dorotatebox\p_framed_orientation\hbox{\box\b_framed_normal}}%
- \d_framed_height\ht\b_framed_normal
- \d_framed_width \wd\b_framed_normal}
+\def\pack_framed_stop_orientation_odd
+ {\swapmacros\framedwidth\framedheight
+ \swapmacros\localwidth\localheight
+ \swapdimens\d_framed_height\d_framed_width
+ \pack_framed_stop_orientation_even}
+
+\def\pack_framed_stop_orientation_even
+ {\setbox\b_framed_normal\hbox{\dorotatebox\p_framed_orientation\hbox{\box\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
@@ -1763,45 +1738,17 @@
\edef\currentmathframed{#1}%
\dosingleempty\pack_framed_mathframed_indeed}
-% \def\pack_framed_mathframed_indeed[#1]#2% no fancy nesting supported here
-% {\iffirstargument
-% \setupcurrentmathframed[#1]%
-% \fi
-% \c_framed_mstyle\mathstyle
-% \doifnot{\mathframedparameter\c!location}\v!low{\let\normalstrut\pack_framed_math_strut}%
-% \inheritedmathframedframed{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
-% \endgroup}
-
-\newcount\c_pack_framed_mc
-
-\def\pack_framed_math_pos
- {\global\advance\c_pack_framed_mc\plusone
- \xdef\pack_framed_mc_one{mcf:1:\number\c_pack_framed_mc}%
- \xdef\pack_framed_mc_two{mcf:2:\number\c_pack_framed_mc}%
- \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
- \else\ifx\m_framed_location\v!low\else
- \let\normalstrut\pack_framed_math_strut
- \fi\fi
+ \doifnot{\mathframedparameter\c!location}\v!low{\let\normalstrut\pack_framed_math_strut}%
\inheritedmathframedframed{\Ustartmath\triggermathstyle\c_framed_mstyle#2\Ustopmath}%
\endgroup}
-\installframedlocator \v!mathematics
- {}
- {\lower\dimexpr\MPy\pack_framed_mc_two-\MPy\pack_framed_mc_one\relax
- \hbox{\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
@@ -2006,7 +1953,6 @@
\raggedcommand
\pack_framed_do_top
\bgroup
-\synchronizeinlinedirection
\localbegstrut
\aftergroup\localendstrut
\aftergroup\pack_framed_do_bottom
@@ -2028,7 +1974,6 @@
\raggedcenter
\vss
\bgroup
-\synchronizeinlinedirection
\localbegstrut
\aftergroup\localendstrut
\aftergroup\vss
@@ -2051,7 +1996,6 @@
\aftergroup\localendstrut
\aftergroup\vss
\aftergroup\egroup
-\synchronizeinlinedirection
\localbegstrut
\doformatonelinerbox}
@@ -2069,7 +2013,6 @@
\raggedcommand
\pack_framed_do_top
\bgroup
-\synchronizeinlinedirection
\localbegstrut
\aftergroup\localendstrut
\aftergroup\pack_framed_do_bottom
@@ -2093,7 +2036,6 @@
\hbox
\bgroup
\aftergroup\egroup
-\synchronizeinlinedirection
\localstrut
\doformatonelinerbox}
@@ -2107,7 +2049,6 @@
\fi
\pack_framed_do_setups
\hss
-\synchronizeinlinedirection
\localstrut
\bgroup
\aftergroup\hss
@@ -2122,7 +2063,6 @@
\fi
\let\postprocessframebox\relax
\pack_framed_do_setups
-\synchronizeinlinedirection
\localstrut
\doformatonelinerbox}
diff --git a/tex/context/base/page-app.mkiv b/tex/context/base/page-app.mkiv
index e4858d48f..5f1c2f297 100644
--- a/tex/context/base/page-app.mkiv
+++ b/tex/context/base/page-app.mkiv
@@ -106,7 +106,7 @@
\fi
\d_page_fitting_width \wd\b_page_fitting
\d_page_fitting_height\ht\b_page_fitting
- \startlocallayout % hm, we change the papersize so we still need it
+ \startlocallayout % still valid?
\let\checkcurrentlayout\relax % else interference with odd/even layout
\processaction
[\fittingpageparameter\c!paper]
@@ -117,7 +117,7 @@
\startmakeup[fittingpage]%
\box\b_page_fitting
\stopmakeup
- \stoplocallayout % we need to get rid of this and use the built-in
+ \stoplocallayout % still valid?
\egroup
\autostoptext}
diff --git a/tex/context/base/page-brk.mkiv b/tex/context/base/page-brk.mkiv
index d1520b6ce..ac1fffd6b 100644
--- a/tex/context/base/page-brk.mkiv
+++ b/tex/context/base/page-brk.mkiv
@@ -228,7 +228,7 @@
\installpagebreakmethod \v!quadruple % not yet ok inside columnsets
{\ifdoublesided
- \ifnum\numexpr\realpageno/\plusfour\relax=\numexpr\realpageno/\plustwo\relax\else
+ \ifnum\numexpr\realpageno/4\relax=\numexpr\realpageno/2\relax\else
\page_breaks_handle_direct\v!yes
\page_breaks_handle_direct\v!empty
\page_breaks_handle_direct\v!empty
diff --git a/tex/context/base/page-flt.lua b/tex/context/base/page-flt.lua
index 11aa2be21..ab7a534eb 100644
--- a/tex/context/base/page-flt.lua
+++ b/tex/context/base/page-flt.lua
@@ -11,6 +11,9 @@ if not modules then modules = { } end modules ['page-flt'] = {
local insert, remove = table.insert, table.remove
local find = string.find
+local setdimen, setcount, texbox = tex.setdimen, tex.setcount, tex.box
+
+local copy_node_list = node.copy_list
local trace_floats = false trackers.register("graphics.floats", function(v) trace_floats = v end) -- name might change
@@ -21,20 +24,10 @@ local C, S, P, lpegmatch = lpeg.C, lpeg.S, lpeg.P, lpeg.match
-- we use floatbox, floatwidth, floatheight
-- text page leftpage rightpage (todo: top, bottom, margin, order)
-local copy_node_list = node.copy_list
-
-local setdimen = tex.setdimen
-local setcount = tex.setcount
-local texgetbox = tex.getbox
-local texsetbox = tex.setbox
-
-floats = floats or { }
-local floats = floats
+floats = floats or { }
+local floats = floats
-local noffloats = 0
-local last = nil
-local default = "text"
-local pushed = { }
+local noffloats, last, default, pushed = 0, nil, "text", { }
local function initialize()
return {
@@ -105,7 +98,7 @@ end
function floats.save(which,data)
which = which or default
- local b = texgetbox("floatbox")
+ local b = texbox.floatbox
if b then
local stack = stacks[which]
noffloats = noffloats + 1
@@ -115,7 +108,7 @@ function floats.save(which,data)
data = data or { },
box = copy_node_list(b),
}
- texsetbox("floatbox",nil)
+ texbox.floatbox = nil
insert(stack,t)
setcount("global","savednoffloats",#stacks[default])
if trace_floats then
@@ -132,10 +125,10 @@ function floats.resave(which)
if last then
which = which or default
local stack = stacks[which]
- local b = texgetbox("floatbox")
+ local b = texbox.floatbox
local w, h, d = b.width, b.height, b.depth
last.box = copy_node_list(b)
- texsetbox("floatbox",nil)
+ texbox.floatbox = nil
insert(stack,1,last)
setcount("global","savednoffloats",#stacks[default])
if trace_floats then
@@ -159,7 +152,7 @@ function floats.flush(which,n,bylabel)
else
interfaces.showmessage("floatblocks",3,t.n)
end
- texsetbox("floatbox",b)
+ texbox.floatbox = b
last = remove(stack,n)
last.box = nil
setcount("global","savednoffloats",#stacks[default]) -- default?
diff --git a/tex/context/base/page-imp.mkiv b/tex/context/base/page-imp.mkiv
index cfa535ab2..c22e9e646 100644
--- a/tex/context/base/page-imp.mkiv
+++ b/tex/context/base/page-imp.mkiv
@@ -293,7 +293,7 @@
\fi
\fi}
-\def\installpagearrangement #1 % will change, no space
+\def\installpagearrangement #1 % will lchange, no space
{\setgvalue{\??layoutarranger#1}}
\def\checkinstalledpagearrangement#1% can be empty: aaa,,bbb
diff --git a/tex/context/base/page-inj.lua b/tex/context/base/page-inj.lua
index 56e5a234e..5b450d60e 100644
--- a/tex/context/base/page-inj.lua
+++ b/tex/context/base/page-inj.lua
@@ -8,8 +8,6 @@ if not modules then modules = { } end modules ["page-inj"] = {
-- Adapted a bit by HH: numbered states, tracking, delayed, order, etc.
-local type, tonumber = type, tonumber
-
local injections = pagebuilders.injections or { }
pagebuilders.injections = injections
@@ -18,11 +16,6 @@ local trace = false trackers.register("pagebuilder.injections",func
local variables = interfaces.variables
-local context = context
-local commands = commands
-
-local texsetcount = tex.setcount
-
local v_yes = variables.yes
local v_previous = variables.previous
local v_next = variables.next
@@ -38,7 +31,7 @@ function injections.save(specification) -- maybe not public, just commands.*
state = tonumber(specification.state) or specification.state,
parameters = specification.userdata,
}
- texsetcount("global","c_page_boxes_flush_n",#cache)
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
end
function injections.flushbefore() -- maybe not public, just commands.*
@@ -69,7 +62,7 @@ function injections.flushbefore() -- maybe not public, just commands.*
end
context.unprotect()
cache = delayed
- texsetcount("global","c_page_boxes_flush_n",#cache)
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
end
end
@@ -99,7 +92,7 @@ function injections.flushafter() -- maybe not public, just commands.*
end
context.protect()
cache = delayed
- texsetcount("global","c_page_boxes_flush_n",#cache)
+ tex.setcount("global","c_page_boxes_flush_n",#cache)
end
end
diff --git a/tex/context/base/page-lay.mkiv b/tex/context/base/page-lay.mkiv
index 81eb0423c..c0d897522 100644
--- a/tex/context/base/page-lay.mkiv
+++ b/tex/context/base/page-lay.mkiv
@@ -597,7 +597,7 @@
\let\p_page_layouts_height\empty
\def\page_layouts_synchronize
- {\setups[\layoutparameter\c!preset]\relax
+ {\setups[\layoutparameter\c!preset]%
\global\leftmarginwidth \layoutparameter\c!leftmargin
\global\rightmarginwidth\layoutparameter\c!rightmargin
\global\leftedgewidth \layoutparameter\c!leftedge
@@ -987,13 +987,14 @@
\global\let\page_adepts_pop\page_adepts_pop_indeed}
\def\page_adapts_check
- {\csname\??pageadaptations\the\ifcsname\??pageadaptations\the\realpageno\endcsname\realpageno\else\zerocount\fi\endcsname}
-
-\def\page_adapts_reset
{\ifcsname\??pageadaptations\the\realpageno\endcsname
- \global\undefinevalue{\??pageadaptations\the\realpageno}%
+ \page_adapts_check_indeed
\fi}
+\def\page_adapts_check_indeed
+ {\getvalue{\??pageadaptations\the\realpageno}%
+ \letvalue{\??pageadaptations\the\realpageno}\relax}
+
\def\page_adepts_push_indeed
{\global\d_page_adepts_pushed_text_height \textheight
\global\d_page_adepts_pushed_footer_height\footerheight}
@@ -1005,9 +1006,6 @@
\global\let\page_adepts_push\page_adepts_push_indeed
\global\let\page_adepts_pop\relax}
-\appendtoks \page_adapts_check \to \everystarttext
-\appendtoks \page_adapts_reset \to \everyshipout
-
\let\page_adepts_pop \relax
\let\page_adepts_push\page_adepts_push_indeed
diff --git a/tex/context/base/page-lin.lua b/tex/context/base/page-lin.lua
index 7e8e9ad8a..e6b500e8b 100644
--- a/tex/context/base/page-lin.lua
+++ b/tex/context/base/page-lin.lua
@@ -12,6 +12,8 @@ local trace_numbers = false trackers.register("lines.numbers", function(v) tra
local report_lines = logs.reporter("lines")
+local texbox = tex.box
+
local attributes, nodes, node, context = attributes, nodes, node, context
nodes.lines = nodes.lines or { }
@@ -21,8 +23,6 @@ lines.data = lines.data or { } -- start step tag
local data = lines.data
local last = #data
-local texgetbox = tex.getbox
-
lines.scratchbox = lines.scratchbox or 0
local leftmarginwidth = nodes.leftmarginwidth
@@ -208,7 +208,7 @@ local function identify(list)
end
function boxed.stage_zero(n)
- return identify(texgetbox(n).list)
+ return identify(texbox[n].list)
end
-- reset ranges per page
@@ -217,9 +217,9 @@ end
function boxed.stage_one(n,nested)
current_list = { }
- local box = texgetbox(n)
- if box then
- local list = box.list
+ local head = texbox[n]
+ if head then
+ local list = head.list
if nested then
list = identify(list)
end
@@ -268,7 +268,7 @@ function boxed.stage_two(n,m)
if #current_list > 0 then
m = m or lines.scratchbox
local t, tn = { }, 0
- for l in traverse_id(hlist_code,texgetbox(m).list) do
+ for l in traverse_id(hlist_code,texbox[m].list) do
tn = tn + 1
t[tn] = copy_node(l)
end
diff --git a/tex/context/base/page-lin.mkiv b/tex/context/base/page-lin.mkiv
index 876d2e781..0f8b78398 100644
--- a/tex/context/base/page-lin.mkiv
+++ b/tex/context/base/page-lin.mkiv
@@ -156,28 +156,28 @@
% todo: text
-\installcorenamespace{linenumberinglocation}
-\installcorenamespace{linenumberingalternative}
-
-\expandafter\let\csname\??linenumberinglocation\v!middle \endcsname \zerocount
-\expandafter\let\csname\??linenumberinglocation\v!left \endcsname \plusone
-\expandafter\let\csname\??linenumberinglocation\v!margin \endcsname \plusone
-\expandafter\let\csname\??linenumberinglocation\v!inmargin \endcsname \plusone
-\expandafter\let\csname\??linenumberinglocation\v!inleft \endcsname \plusone
-\expandafter\let\csname\??linenumberinglocation\v!right \endcsname \plustwo
-\expandafter\let\csname\??linenumberinglocation\v!inright \endcsname \plustwo
-\expandafter\let\csname\??linenumberinglocation\v!inner \endcsname \plusthree
-\expandafter\let\csname\??linenumberinglocation\v!outer \endcsname \plusfour
-\expandafter\let\csname\??linenumberinglocation\v!text \endcsname \plusfive
-\expandafter\let\csname\??linenumberinglocation\v!begin \endcsname \plussix
-\expandafter\let\csname\??linenumberinglocation\v!end \endcsname \plusseven
-
-\expandafter\let\csname\??linenumberingalternative\v!middle \endcsname \zerocount
-\expandafter\let\csname\??linenumberingalternative\v!right \endcsname \plusone
-\expandafter\let\csname\??linenumberingalternative\v!flushleft \endcsname \plusone
-\expandafter\let\csname\??linenumberingalternative\v!left \endcsname \plustwo
-\expandafter\let\csname\??linenumberingalternative\v!flushright\endcsname \plustwo
-\expandafter\let\csname\??linenumberingalternative\v!auto \endcsname \plusfive
+\installcorenamespace{linennumberinglocation}
+\installcorenamespace{linennumberingalternative}
+
+\expandafter\let\csname\??linennumberinglocation\v!middle \endcsname \zerocount
+\expandafter\let\csname\??linennumberinglocation\v!left \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!margin \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!inmargin \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!inleft \endcsname \plusone
+\expandafter\let\csname\??linennumberinglocation\v!right \endcsname \plustwo
+\expandafter\let\csname\??linennumberinglocation\v!inright \endcsname \plustwo
+\expandafter\let\csname\??linennumberinglocation\v!inner \endcsname \plusthree
+\expandafter\let\csname\??linennumberinglocation\v!outer \endcsname \plusfour
+\expandafter\let\csname\??linennumberinglocation\v!text \endcsname \plusfive
+\expandafter\let\csname\??linennumberinglocation\v!begin \endcsname \plussix
+\expandafter\let\csname\??linennumberinglocation\v!end \endcsname \plusseven
+
+\expandafter\let\csname\??linennumberingalternative\v!middle \endcsname \zerocount
+\expandafter\let\csname\??linennumberingalternative\v!right \endcsname \plusone
+\expandafter\let\csname\??linennumberingalternative\v!flushleft \endcsname \plusone
+\expandafter\let\csname\??linennumberingalternative\v!left \endcsname \plustwo
+\expandafter\let\csname\??linennumberingalternative\v!flushright\endcsname \plustwo
+\expandafter\let\csname\??linennumberingalternative\v!auto \endcsname \plusfive
% \startlinenumbering[|continue|settings|name]
% \startlinenumbering[name][|continue|settings]
@@ -339,8 +339,8 @@
\else
\setfalse\c_page_lines_fake_number
\fi
- \c_page_lines_location \executeifdefined{\??linenumberinglocation \linenumberingparameter\c!location}\plusone \relax % left
- \c_page_lines_alignment\executeifdefined{\??linenumberingalternative\linenumberingparameter\c!align }\plusfive\relax % auto
+ \c_page_lines_location \executeifdefined{\??linennumberinglocation \linenumberingparameter\c!location}\plusone \relax % left
+ \c_page_lines_alignment\executeifdefined{\??linennumberingalternative\linenumberingparameter\c!align }\plusfive\relax % auto
\ifcase\c_page_lines_last_column\relax
\settrue \c_page_lines_fake_number
\or
diff --git a/tex/context/base/page-mix.lua b/tex/context/base/page-mix.lua
index 7a97655d2..cf0094787 100644
--- a/tex/context/base/page-mix.lua
+++ b/tex/context/base/page-mix.lua
@@ -34,14 +34,11 @@ local new_glue = nodepool.glue
local hpack = node.hpack
local vpack = node.vpack
local freenode = node.free
-local concatnodes = nodes.concat
-
-local texgetbox = tex.getbox
-local texsetbox = tex.setbox
-local texgetskip = tex.getskip
+local texbox = tex.box
+local texskip = tex.skip
+local texdimen = tex.dimen
local points = number.points
-
local settings_to_hash = utilities.parsers.settings_to_hash
local variables = interfaces.variables
@@ -82,7 +79,7 @@ local function collectinserts(result,nxt,nxtid)
if not c then
c = { }
inserts[s] = c
- local width = texgetskip(s).width
+ local width = texskip[s].width
if not result.inserts[s] then
currentskips = currentskips + width
end
@@ -136,10 +133,15 @@ local function discardtopglue(current,discarded)
if current.penalty == forcedbreak then
discarded[#discarded+1] = current
current = current.next
- while current and current.id == glue_code do
- size = size + current.spec.width
- discarded[#discarded+1] = current
- current = current.next
+ while current do
+ local id = current.id
+ if id == glue_code then
+ size = size + current.spec.width
+ discarded[#discarded+1] = current
+ current = current.next
+ else
+ break
+ end
end
else
discarded[#discarded+1] = current
@@ -197,7 +199,7 @@ local function setsplit(specification) -- a rather large function
report_state("fatal error, no box")
return
end
- local list = texgetbox(box)
+ local list = texbox[box]
if not list then
report_state("fatal error, no list")
return
@@ -216,10 +218,6 @@ local function setsplit(specification) -- a rather large function
local height = 0
local depth = 0
local skip = 0
- local splitmethod = specification.splitmethod or false
- if splitmethod == v_none then
- splitmethod = false
- end
local options = settings_to_hash(specification.option or "")
local stripbottom = specification.alternative == v_local
local cycle = specification.cycle or 1
@@ -255,35 +253,12 @@ local function setsplit(specification) -- a rather large function
delta = 0,
}
end
-
local column = 1
local line = 0
- local result = results[1]
+ local result = results[column]
local lasthead = nil
local rest = nil
-
- if trace_state then
- report_state("setting collector to column %s",column)
- end
-
- local lastlocked = nil
- local lastcurrent = nil
-
- local backtracked = false
-
local function gotonext()
- if lastcurrent then
- if current ~= lastcurrent then
- if trace_state then
- report_state("backtracking to preferred break in column %s",column)
- end
- -- todo: also remember height/depth
- current = lastcurrent
- backtracked = true
- end
- lastcurrent = nil
- lastlocked = nil
- end
if head == lasthead then
if trace_state then
report_state("empty column %s, needs more work",column)
@@ -307,21 +282,19 @@ local function setsplit(specification) -- a rather large function
if column == nofcolumns then
column = 0 -- nicer in trace
rest = head
+ -- lasthead = head
return false, 0
else
local skipped
column = column + 1
result = results[column]
- if trace_state then
- report_state("setting collector to column %s",column)
- end
current, skipped = discardtopglue(current,discarded)
head = current
+ -- lasthead = head
return true, skipped
end
end
-
- local function checked(advance,where,locked)
+ local function checked(advance,where)
local total = skip + height + depth + advance
local delta = total - target
local state = "same"
@@ -343,34 +316,47 @@ local function setsplit(specification) -- a rather large function
end
return state, skipped
end
-
current, skipped = discardtopglue(current,discarded)
if trace_detail and skipped ~= 0 then
report_state("check > column 1, discarded %p",skipped)
end
-
- -- problem: when we cannot break after a list (and we only can expect same-page situations as we don't
- -- care too much about weighted breaks here) we should sort of look ahead or otherwise be able to push
- -- back inserts and so
- --
- -- ok, we could use vsplit but we don't have that one opened up yet .. maybe i should look into the c-code
- -- .. something that i try to avoid so let's experiment more before we entry dirty trick mode
-
head = current
-
- local function process_skip(current,nxt)
- local advance = current.spec.width
- local prv = current.prev
- if prv.id == penalty_code then
- local penalty = prv.penalty
- if penalty < 4000 then
- lastlocked = nil
- lastcurrent = nil
+ while current do
+ local id = current.id
+ local nxt = current.next
+local lastcolumn = column
+ if id == hlist_code or id == vlist_code then
+ line = line + 1
+ local nxtid = nxt and nxt.id
+ local inserts, currentskips, nextskips, inserttotal = nil, 0, 0, 0
+ local advance = current.height -- + current.depth
+ if nxt and (nxtid == insert_code or nxtid == mark_code) then
+ nxt, inserts, localskips, insertskips, inserttotal = collectinserts(result,nxt,nxtid)
+ end
+ local state, skipped = checked(advance+inserttotal+currentskips,"line")
+ if trace_state then
+ report_state("%-7s > column %s, state %a, line %s, advance %p, insert %p, height %p","line",column,state,line,advance,inserttotal,height)
+ if skipped ~= 0 then
+ report_state("%-7s > column %s, discarded %p","line",column,skipped)
+ end
+ end
+ if state == "quit" then
+ break
+ else
+ height = height + depth + skip + advance + inserttotal
+ if state == "next" then
+ height = height + nextskips
+ else
+ height = height + currentskips
end
- elseif current.subtype ~= lineskip_code then
- lastlocked = nil
- lastcurrent = nil
end
+ depth = current.depth
+ skip = 0
+ if inserts then
+ appendinserts(result.inserts,inserts)
+ end
+ elseif id == glue_code then
+ local advance = current.spec.width
if advance ~= 0 then
local state, skipped = checked(advance,"glue")
if trace_state then
@@ -380,222 +366,60 @@ local function setsplit(specification) -- a rather large function
end
end
if state == "quit" then
- return true
+ break
end
height = height + depth + skip
depth = 0
skip = height > 0 and advance or 0
- if trace_state then
- report_state("%-7s > column %s, height %p, depth %p, skip %p","glue",column,height,depth,skip)
- end
- else
- -- what else? ignore? treat as valid as usual?
- end
- end
-
- local function process_kern(current,nxt)
- local advance = current.kern
- if advance ~= 0 then
- local state, skipped = checked(advance,"kern")
- if trace_state then
- report_state("%-7s > column %s, state %a, advance %p, height %p, state %a","kern",column,state,advance,height)
- if skipped ~= 0 then
- report_state("%-7s > column %s, discarded %p","kern",column,skipped)
- end
- end
- if state == "quit" then
- return true
end
- height = height + depth + skip + advance
- depth = 0
- skip = 0
- if trace_state then
- report_state("%-7s > column %s, height %p, depth %p, skip %p","kern",column,height,depth,skip)
- end
- end
- end
-
- local function process_rule(current,nxt)
- -- simple variant of h|vlist
- local advance = current.height -- + current.depth
- local state, skipped = checked(advance+currentskips,"rule")
- if trace_state then
- report_state("%-7s > column %s, state %a, rule, advance %p, height %p","line",column,state,advance,inserttotal,height)
- if skipped ~= 0 then
- report_state("%-7s > column %s, discarded %p","rule",column,skipped)
- end
- end
- if state == "quit" then
- return true
- end
- height = height + depth + skip + advance
- if state == "next" then
- height = height + nextskips
- else
- height = height + currentskips
- end
- depth = current.depth
- skip = 0
- end
-
- -- okay, here we could do some badness like magic but we want something
- -- predictable and even better: strategies .. so eventually this will
- -- become installable
- --
- -- [chapter] [penalty] [section] [penalty] [first line]
- --
- -- we need some nice use cases so the next is just for me to play with
-
- -- todo: presets:
- --
- -- fixed : criterium=4000 check=no
- -- large : criterium=4000 check=more
- -- auto : criterium=0 check=more
-
- local lockcriterium = 4000
-
- local function prevprev(current)
- local p = current.prev
- return p and p.prev
- end
-
- local function reassess(current,penalty)
- if splitmethod == v_fixed then
- -- quite ok, a magic number: used as samepage (in sectioning)
- if penalty >= lockcriterium then
- if not lastlocked then
- lastcurrent = prevprev(current)
- lastlocked = lastcurrent and penalty
- end
- return
- end
- elseif splitmethod == v_more then
- -- experiment, might change
- if penalty >= lockcriterium then
- if not lastlocked or penalty >= lastlocked then
- lastcurrent = prevprev(current)
- lastlocked = lastcurrent and penalty
- end
- return
- end
- elseif splitmethod == v_auto then
- if penalty > 0 then
- if not lastlocked or penalty > lastlocked then
- lastcurrent = prevprev(current)
- lastlocked = lastcurrent and penalty
- end
- return
- end
- end
- lastlocked = nil
- lastcurrent = nil
- end
-
- local function process_penalty(current,nxt)
- local penalty = current.penalty
- if penalty == 0 then
- lastlocked = nil
- lastcurrent = nil
- elseif penalty == forcedbreak then
- lastlocked = nil
- lastcurrent = nil
- local okay, skipped = gotonext()
- if okay then
+ elseif id == kern_code then
+ local advance = current.kern
+ if advance ~= 0 then
+ local state, skipped = checked(advance,"kern")
if trace_state then
- report_state("cycle: %s, forced column break, same page",cycle)
+ report_state("%-7s > column %s, state %a, advance %p, height %p, state %a","kern",column,state,advance,height)
if skipped ~= 0 then
- report_state("%-7s > column %s, discarded %p","penalty",column,skipped)
+ report_state("%-7s > column %s, discarded %p","kern",column,skipped)
end
end
- else
- if trace_state then
- report_state("cycle: %s, forced column break, next page",cycle)
- if skipped ~= 0 then
- report_state("%-7s > column %s, discarded %p","penalty",column,skipped)
- end
+ if state == "quit" then
+ break
end
- return true
- end
- elseif penalty < 0 then
- -- we don't care too much
- lastlocked = nil
- lastcurrent = nil
- elseif splitmethod then
- reassess(current,penalty)
- else
- lastlocked = nil
- lastcurrent = nil
- end
- end
-
- local function process_list(current,nxt)
- local nxtid = nxt and nxt.id
- line = line + 1
- local inserts, currentskips, nextskips, inserttotal = nil, 0, 0, 0
- local advance = current.height -- + current.depth
- if trace_state then
- report_state("%-7s > column %s, content: %s","line",column,listtoutf(current.list,true,true))
- end
- if nxt and (nxtid == insert_code or nxtid == mark_code) then
- nxt, inserts, localskips, insertskips, inserttotal = collectinserts(result,nxt,nxtid)
- end
- local state, skipped = checked(advance+inserttotal+currentskips,"line",lastlocked)
- if trace_state then
- report_state("%-7s > column %s, state %a, line %s, advance %p, insert %p, height %p","line",column,state,line,advance,inserttotal,height)
- if skipped ~= 0 then
- report_state("%-7s > column %s, discarded %p","line",column,skipped)
+ height = height + depth + skip + advance
+ depth = 0
+ skip = 0
end
- end
- if state == "quit" then
- return true
- end
- height = height + depth + skip + advance + inserttotal
- if state == "next" then
- height = height + nextskips
- else
- height = height + currentskips
- end
- depth = current.depth
- skip = 0
- if inserts then
- -- so we already collect them ... makes backtracking tricky ... alternatively
- -- we can do that in a separate loop ... no big deal either
- appendinserts(result.inserts,inserts)
- end
- if trace_state then
- report_state("%-7s > column %s, height %p, depth %p, skip %p","line",column,height,depth,skip)
- end
- end
-
- while current do
-
- local id = current.id
- local nxt = current.next
-
- backtracked = false
-
- -- print("process",nodetostring(current))
-
- if id == hlist_code or id == vlist_code then
- if process_list(current,nxt) then break end
- elseif id == glue_code then
- if process_skip(current,nxt) then break end
- elseif id == kern_code then
- if process_kern(current,nxt) then break end
elseif id == penalty_code then
- if process_penalty(current,nxt) then break end
- elseif id == rule_code then
- if process_rule(current,nxt) then break end
- else
- end
-
- if backtracked then
- -- print("pickup",nodetostring(current))
- nxt = current
- else
- -- print("move on",nodetostring(current))
+ local penalty = current.penalty
+ if penalty == 0 then
+ -- don't bother
+ elseif penalty == forcedbreak then
+ local okay, skipped = gotonext()
+ if okay then
+ if trace_state then
+ report_state("cycle: %s, forced column break (same page)",cycle)
+ if skipped ~= 0 then
+ report_state("%-7s > column %s, discarded %p","penalty",column,skipped)
+ end
+ end
+ else
+ if trace_state then
+ report_state("cycle: %s, forced column break (next page)",cycle)
+ if skipped ~= 0 then
+ report_state("%-7s > column %s, discarded %p","penalty",column,skipped)
+ end
+ end
+ break
+ end
+ else
+ -- todo: nobreak etc ... we might need to backtrack so we need to remember
+ -- the last acceptable break
+ -- club and widow and such i.e. resulting penalties (if we care)
+ end
end
-
+if lastcolumn == column then
+ nxt = current.next -- can have changed
+end
if nxt then
current = nxt
elseif head == lasthead then
@@ -613,7 +437,6 @@ local function setsplit(specification) -- a rather large function
break
end
end
-
if not current then
if trace_state then
report_state("nilling rest")
@@ -643,7 +466,7 @@ local function setsplit(specification) -- a rather large function
specification.overflow = overflow
specification.discarded = discarded
- texgetbox(specification.box).list = nil
+ texbox[specification.box].head = nil
return specification
end
@@ -733,6 +556,9 @@ function mixedcolumns.setsplit(specification)
end
end
+local topskip_code = gluecodes.topskip
+local baselineskip_code = gluecodes.baselineskip
+
function mixedcolumns.getsplit(result,n)
if not result then
report_state("flush, column %s, no result",n)
@@ -789,10 +615,9 @@ function mixedcolumns.getsplit(result,n)
end
for c, list in next, r.inserts do
- local l = concatnodes(list)
- local b = vpack(l) -- multiple arguments, todo: fastvpack
- -- texsetbox("global",c,b)
- texsetbox(c,b)
+ -- tex.setbox("global",c,vpack(nodes.concat(list)))
+ -- tex.setbox(c,vpack(nodes.concat(list)))
+ texbox[c] = vpack(nodes.concat(list))
r.inserts[c] = nil
end
diff --git a/tex/context/base/page-mix.mkiv b/tex/context/base/page-mix.mkiv
index a40418d58..abdcced1f 100644
--- a/tex/context/base/page-mix.mkiv
+++ b/tex/context/base/page-mix.mkiv
@@ -28,7 +28,6 @@
% top and bottom inserts
% wide floats
% move floats
-% offsets (inner ones, so we change the hsize ... needed with backgrounds
% luatex buglet:
%
@@ -56,11 +55,7 @@
\setupmixedcolumns
[\c!distance=1.5\bodyfontsize,
\c!n=\plustwo,
- %\c!align=, % inherit
- %\c!before=,
- %\c!after=,
- %\c!separator=\v!none,
- %\c!setups=,
+ %\c!rule=\v!none,
\c!frame=\v!off,
\c!strut=\v!no,
\c!offset=\v!overlay,
@@ -69,7 +64,6 @@
\c!maxwidth=\makeupwidth,
\c!grid=\v!tolerant,
\c!step=.25\lineheight, % needs some experimenting
- %\c!splitmethod=\v!fixed, % will be default
\c!method=\ifinner\s!box\else\s!otr\fi] % automatic as suggested by WS
\let\startmixedcolumns\relax % defined later
@@ -164,8 +158,7 @@
\definemixedcolumns
[\s!itemgroupcolumns]
[\c!n=\itemgroupparameter\c!n,
- \c!separator=\v!none,
- \c!splitmethod=\v!none,
+ \c!rule=\v!off,
\c!balance=\v!yes]
\unexpanded\def\strc_itemgroups_start_columns
@@ -226,7 +219,7 @@
\unexpanded\def\page_mix_command_set_hsize
{\hsize\d_page_mix_column_width
- \textwidth\d_page_mix_column_width}
+ \textwidth\d_page_mul_used_width} % needs thinking ... grouping etc
%D When setting the vsize we make sure that we collect a few more lines than needed
%D so that we have enough to split over the columns. Collecting too much is somewhat
@@ -296,7 +289,7 @@
\unexpanded\def\page_mix_command_inject_separator
{\bgroup
\hss
- \csname\??mixedcolumnsseparator\mixedcolumnsparameter\c!separator\endcsname % was \c!rule
+ \csname\??mixedcolumnsseparator\mixedcolumnsparameter\c!separator\endcsname
\hss
\egroup}
@@ -485,21 +478,12 @@
%
\page_mix_command_set_vsize
\page_mix_command_set_hsize
- \fi
- \usealignparameter\mixedcolumnsparameter
- \usesetupsparameter\mixedcolumnsparameter}
-
-% \setvalue{\??mixedcolumnsstop\s!otr}%
-% {\par
-% \ifcase\c_page_mix_otr_nesting\or
-% \c_page_mix_routine\c_page_mix_routine_balance
-% \page_otr_trigger_output_routine
-% \fi}
+ \fi}
\setvalue{\??mixedcolumnsstop\s!otr}%
{\par
\ifcase\c_page_mix_otr_nesting\or
- \doif{\mixedcolumnsparameter\c!balance}\v!yes{\c_page_mix_routine\c_page_mix_routine_balance}%
+ \c_page_mix_routine\c_page_mix_routine_balance
\page_otr_trigger_output_routine
\fi}
@@ -527,7 +511,6 @@
strutht = \number\strutht,
strutdp = \number\strutdp,
threshold = \number\d_page_mix_threshold,
- splitmethod = "\mixedcolumnsparameter\c!splitmethod",
balance = "#1",
alternative = "\mixedcolumnsparameter\c!alternative",
grid = \ifgridsnapping true\else false\fi,
@@ -544,14 +527,10 @@
\fi
\hskip\d_page_mix_leftskip
\page_mix_hbox to \d_page_mix_max_width \bgroup
- \dorecurse\c_page_mix_n_of_columns{%
- % needs packaging anyway
- \setbox\scratchbox\page_mix_command_package_column
- % for the moment a quick and dirty patch .. we need to go into the box (hence the \plusone) .. a slowdowner
- \page_lines_add_numbers_to_box\scratchbox\recurselevel\c_page_mix_n_of_columns\plusone
- % the framed needs a reset of strut, align, setups etc
- \inheritedmixedcolumnsframedbox\currentmixedcolumns\scratchbox
- % optional
+ \letmixedcolumnsparameter\c!strut\v!no
+ % maybe use \c_page_mix_used_of_columns
+ \dorecurse\c_page_mix_n_of_columns {%
+ \inheritedmixedcolumnsframed{\page_mix_command_package_column}%
\ifnum\recurselevel<\c_page_mix_n_of_columns
\page_mix_command_inject_separator
\fi
diff --git a/tex/context/base/page-mrk.mkiv b/tex/context/base/page-mrk.mkiv
index 6d0a5af94..5f8d332c5 100644
--- a/tex/context/base/page-mrk.mkiv
+++ b/tex/context/base/page-mrk.mkiv
@@ -173,7 +173,6 @@
\settrue\c_page_marks_add_more_number}
\appendtoks
- \setfalse\c_page_marks_add_page_lines
\setfalse\c_page_marks_add_more_color
\setfalse\c_page_marks_add_more_marking
\setfalse\c_page_marks_add_more_lines
diff --git a/tex/context/base/page-mul.mkiv b/tex/context/base/page-mul.mkiv
index 24286106a..9e0861af9 100644
--- a/tex/context/base/page-mul.mkiv
+++ b/tex/context/base/page-mul.mkiv
@@ -1158,28 +1158,26 @@
\def\setlocalcolumnfloats
{\settrue\onlylocalcolumnfloats
\everypar\everylocalcolumnfloatspar
- \let\page_mul_flush_float \doflushcolumnfloat
+ \let\page_mul_flush_float\doflushcolumnfloat
\let\page_mul_flush_floats\doflushcolumnfloats}
\def\setglobalcolumnfloats
{\setfalse\onlylocalcolumnfloats
\reseteverypar
- \let\page_mul_flush_float \relax
+ \let\page_mul_flush_float\relax
\let\page_mul_flush_floats\noflushcolumnfloats}
- % \def\noflushcolumnfloats
- % {\bgroup
- % \xdef\localsavednoffloats{\the\savednoffloats}%
- % \global\savednoffloats\globalsavednoffloats
- % \page_otr_command_flush_top_insertions
- % \xdef\globalsavenoffloats{\the\savednoffloats}%
- % \ifnum\globalsavednoffloats=\zerocount
- % \setlocalcolumnfloats
- % \fi
- % \global\savednoffloats\localsavednoffloats
- % \egroup}
- %
- \def\noflushcolumnfloats{\doflushcolumnfloats} % not yet redone
+ \def\noflushcolumnfloats
+ {\bgroup
+ \xdef\localsavednoffloats{\the\savednoffloats}%
+ \global\savednoffloats\globalsavednoffloats
+ \page_otr_command_flush_top_insertions
+ \xdef\globalsavenoffloats{\the\savednoffloats}%
+ \ifnum\globalsavednoffloats=\zerocount
+ \setlocalcolumnfloats
+ \fi
+ \global\savednoffloats\localsavednoffloats
+ \egroup}
%D We need to calculate the amount of free space in a columns. When there is not
%D enough room, we migrate the float to the next column. These macro's are
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index 941828688..6261938b6 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -1,4 +1,4 @@
- %D \module
+%D \module
%D [ file=page-one,
%D version=2000.10.20,
%D title=\CONTEXT\ Page Macros,
diff --git a/tex/context/base/page-pst.lua b/tex/context/base/page-pst.lua
index 50580ae33..8586830cf 100644
--- a/tex/context/base/page-pst.lua
+++ b/tex/context/base/page-pst.lua
@@ -8,23 +8,15 @@ if not modules then modules = { } end modules ['page-pst'] = {
-- todo: adapt message
-local tonumber, next = tonumber, next
local format, validstring = string.format, string.valid
local sortedkeys = table.sortedkeys
-local context = context
-local commands = commands
-
-local texgetcount = tex.getcount
-local texsetcount = tex.setcount
-
local cache = { }
local function flush(page)
local c = cache[page]
if c then
for i=1,#c do
- -- characters.showstring(c[i])
context.viafile(c[i],format("page.%s",validstring(page,"nopage")))
end
cache[page] = nil
@@ -40,14 +32,14 @@ local function setnextpage()
elseif n > 0 then
-- upcoming page (realpageno)
end
- texsetcount("global","c_page_postponed_blocks_next_page",n)
+ tex.setcount("global","c_page_postponed_blocks_next_page",n)
end
function commands.flushpostponedblocks(page)
-- we need to flush previously pending pages as well and the zero
-- slot is the generic one so that one is always flushed
local t = sortedkeys(cache)
- local p = tonumber(page) or texgetcount("realpageno") or 0
+ local p = tonumber(page) or tex.count.realpageno or 0
for i=1,#t do
local ti = t[i]
if ti <= p then
@@ -62,7 +54,7 @@ end
function commands.registerpostponedblock(page)
if type(page) == "string" then
if string.find(page,"^+") then
- page = texgetcount("realpageno") + (tonumber(page) or 1) -- future delta page
+ page = tex.count.realpageno + (tonumber(page) or 1) -- future delta page
else
page = tonumber(page) or 0 -- preferred page or otherwise first possible occasion
end
diff --git a/tex/context/base/page-pst.mkiv b/tex/context/base/page-pst.mkiv
index 704289246..7f8a39ca6 100644
--- a/tex/context/base/page-pst.mkiv
+++ b/tex/context/base/page-pst.mkiv
@@ -78,7 +78,6 @@
%\flushrestfloats
\page_floats_flush_page_floats
\setnormalcatcodes % postponing in verbatim
- \uncatcodespacetokens % postponing in startlines
\restoreglobalbodyfont % otherwise problems inside split verbatim
\ctxcommand{flushpostponedblocks()}%
\relax
diff --git a/tex/context/base/page-str.lua b/tex/context/base/page-str.lua
index 35ce85609..f6314657f 100644
--- a/tex/context/base/page-str.lua
+++ b/tex/context/base/page-str.lua
@@ -12,25 +12,18 @@ if not modules then modules = { } end modules ['page-str'] = {
local concat, insert, remove = table.concat, table.insert, table.remove
-local nodes, node = nodes, node
-
-local nodepool = nodes.pool
-local tasks = nodes.tasks
-
-local new_kern = nodepool.kern
-local new_glyph = nodepool.glyph
+local find_tail, write_node, free_node, copy_nodelist = node.slide, node.write, node.free, node.copy_list
+local vpack_nodelist, hpack_nodelist = node.vpack, node.hpack
+local texdimen, texbox = tex.dimen, tex.box
+local settings_to_array = utilities.parsers.settings_to_array
-local find_tail = node.slide
-local write_node = node.write
-local free_node = node.free
-local copy_nodelist = node.copy_list
-local vpack_nodelist = node.vpack
-local hpack_nodelist = node.hpack
+local nodes, node = nodes, node
-local settings_to_array = utilities.parsers.settings_to_array
+local nodepool = nodes.pool
+local tasks = nodes.tasks
-local texgetdimen = tex.getdimen
-local texgetbox = tex.getbox
+local new_kern = nodepool.kern
+local new_glyph = nodepool.glyph
local trace_collecting = false trackers.register("streams.collecting", function(v) trace_collecting = v end)
local trace_flushing = false trackers.register("streams.flushing", function(v) trace_flushing = v end)
@@ -182,8 +175,7 @@ function streams.synchronize(list) -- this is an experiment !
if trace_flushing then
report_streams("slot %s has max height %p and max depth %p",m,height,depth)
end
- local strutht = texgetdimen("globalbodyfontstrutheight")
- local strutdp = texgetdimen("globalbodyfontstrutdepth")
+ local strutht, strutdp = texdimen.globalbodyfontstrutheight, texdimen.globalbodyfontstrutdepth
local struthtdp = strutht + strutdp
for i=1,#list do
local name = list[i]
@@ -206,7 +198,7 @@ function streams.synchronize(list) -- this is an experiment !
local n, delta = 0, delta_height -- for tracing
while delta > 0 do
-- we need to add some interline penalties
- local line = copy_nodelist(texgetbox("strutbox"))
+ local line = copy_nodelist(tex.box.strutbox)
line.height, line.depth = strutht, strutdp
if tail then
tail.next, line.prev = line, tail
diff --git a/tex/context/base/page-txt.mkvi b/tex/context/base/page-txt.mkvi
index 240f0e00b..707af25e9 100644
--- a/tex/context/base/page-txt.mkvi
+++ b/tex/context/base/page-txt.mkvi
@@ -269,7 +269,7 @@
\let\m_page_layouts_element_content\empty
\unexpanded\def\page_layouts_process_element_single#style#color#width#content%
- {\edef\m_page_layouts_element_content{\detokenize{#content}}% so no \v!xxx
+ {\edef\m_page_layouts_element_content{\detokenize{#content}}%
\ifx\m_page_layouts_element_content\empty
% should not happen too often
\else
diff --git a/tex/context/base/phys-dim.lua b/tex/context/base/phys-dim.lua
index e40d1eabb..45a99978d 100644
--- a/tex/context/base/phys-dim.lua
+++ b/tex/context/base/phys-dim.lua
@@ -53,9 +53,6 @@ local variables = interfaces.variables
local v_reverse = variables.reverse
local allocate = utilities.storage.allocate
-local context = context
-local commands = commands
-
local trace_units = false
local report_units = logs.reporter("units")
@@ -384,15 +381,13 @@ local long_operators = {
local long_suffixes = {
- Linear = "linear",
- Square = "square",
- Cubic = "cubic",
- Quadratic = "quadratic",
- Inverse = "inverse",
- ILinear = "ilinear",
- ISquare = "isquare",
- ICubic = "icubic",
- IQuadratic = "iquadratic",
+ Linear = "linear",
+ Square = "square",
+ Cubic = "cubic",
+ Inverse = "inverse",
+ ILinear = "ilinear",
+ ISquare = "isquare",
+ ICubic = "icubic",
}
@@ -459,29 +454,23 @@ local short_suffixes = { -- maybe just raw digit match
["1"] = "linear",
["2"] = "square",
["3"] = "cubic",
- ["4"] = "quadratic",
["+1"] = "linear",
["+2"] = "square",
["+3"] = "cubic",
- ["+4"] = "quadratic",
["-1"] = "inverse",
["-1"] = "ilinear",
["-2"] = "isquare",
["-3"] = "icubic",
- ["-4"] = "iquadratic",
["^1"] = "linear",
["^2"] = "square",
["^3"] = "cubic",
- ["^4"] = "quadratic",
["^+1"] = "linear",
["^+2"] = "square",
["^+3"] = "cubic",
- ["^+4"] = "quadratic",
["^-1"] = "inverse",
["^-1"] = "ilinear",
["^-2"] = "isquare",
["^-3"] = "icubic",
- ["^-4"] = "iquadratic",
}
local symbol_units = {
@@ -586,7 +575,7 @@ labels.units = allocate {
lumen = { labels = { en = [[lm]] } },
lux = { labels = { en = [[lx]] } },
bequerel = { labels = { en = [[Bq]] } },
- gray = { labels = { en = [[Gy]] } },
+ gray = { labels = { en = [[Gr]] } },
sievert = { labels = { en = [[Sv]] } },
katal = { labels = { en = [[kat]] } },
minute = { labels = { en = [[min]] } },
@@ -646,15 +635,13 @@ labels.operators = allocate {
}
labels.suffixes = allocate {
- linear = { labels = { en = [[1]] } },
- square = { labels = { en = [[2]] } },
- cubic = { labels = { en = [[3]] } },
- quadratic = { labels = { en = [[4]] } },
- inverse = { labels = { en = [[-1]] } },
- ilinear = { labels = { en = [[-1]] } },
- isquare = { labels = { en = [[-2]] } },
- icubic = { labels = { en = [[-3]] } },
- iquadratic = { labels = { en = [[-4]] } },
+ linear = { labels = { en = [[1]] } },
+ square = { labels = { en = [[2]] } },
+ cubic = { labels = { en = [[3]] } },
+ inverse = { labels = { en = [[-1]] } },
+ ilinear = { labels = { en = [[-1]] } },
+ isquare = { labels = { en = [[-2]] } },
+ icubic = { labels = { en = [[-3]] } },
}
local function dimpus(p,u,s)
diff --git a/tex/context/base/s-abr-01.tex b/tex/context/base/s-abr-01.tex
index 7d8064b29..026f2ea09 100644
--- a/tex/context/base/s-abr-01.tex
+++ b/tex/context/base/s-abr-01.tex
@@ -232,7 +232,6 @@
\logo [SQL] {sql}
\logo [SSD] {ssd}
\logo [SVG] {svg}
-\logo [STIX] {Stix}
\logo [SWIG] {swig}
\logo [SWIGLIB] {SwigLib}
\logo [TABLE] {\TaBlE}
@@ -300,7 +299,6 @@
\logo [XFDF] {xfdf}
\logo [XHTML] {xhtml}
\logo [XINDY] {Xindy}
-\logo [XITS] {Xits}
\logo [XML] {xml}
\logo [XPATH] {xpath}
\logo [XMLTOOLS] {xmltools}
diff --git a/tex/context/base/s-abr-04.tex b/tex/context/base/s-abr-04.tex
index 23940b526..dcd93c6f1 100644
--- a/tex/context/base/s-abr-04.tex
+++ b/tex/context/base/s-abr-04.tex
@@ -1,8 +1,8 @@
%D \module
-%D [ file=s-abr-04,
+%D [ file=s-abr-01,
%D version=1996.01.01,
%D title=\CONTEXT\ Style File,
-%D subtitle=General Abbreviations 2,
+%D subtitle=General Abbreviations 1,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
@@ -11,14 +11,314 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\usemodule[abr-01]
-
\unprotect
-% \definealternativestyle [\v!mixed] [\font_style_pseudoMixedCapped] [\font_style_pseudoMixedCapped]
-
-\setupsorting[logo][\c!style=\font_style_pseudoMixedCapped]
+% \setupsorting[logo][\c!style=\v!capital]
% \setupcapitals[\c!title=\v!no]
-\protect \endinput
+\protect
+
+\logo [MKI] {MkI}
+\logo [MKII] {MkII}
+\logo [MKIII] {MkIII}
+\logo [MKIV] {MkIV}
+
+%logo [FGA] {fga}
+%logo [FGBBS] {fgbbs}
+\logo [ACROBAT] {Acro\-bat}
+\logo [AFM] {afm}
+\logo [API] {api}
+\logo [ALEPH] {Aleph} % {\mathematics{\aleph}}
+\logo [ALGOL] {ALGOL}
+\logo [AMS] {ams}
+\logo [AMSLATEX] {AmS\LATEX}
+\logo [AMSTEX] {AmS\TeX}
+\logo [ANSI] {ansi}
+\logo [ARABTEX] {Arab\TeX}
+\logo [ASCII] {ascii}
+\logo [ASCIITEX] {ascii\TeX}
+\logo [BACHOTEX] {Bacho\TeX}
+\logo [BIBTEX] {bib\TeX}
+\logo [BLUESKY] {BlueSky}
+\logo [BMP] {bmp}
+\logo [BSD] {bsd}
+\logo [CCODE] {c}
+\logo [CALCMATH] {CalcMath}
+\logo [CD] {cd}
+\logo [CLD] {cld}
+\logo [CPU] {cpu}
+\logo [CDROM] {cdrom}
+\logo [CID] {cid}
+\logo [CJK] {cjk}
+\logo [CMR] {cmr}
+\logo [CMYK] {cmyk}
+\logo [CODHOST] {CodHost}
+\logo [CONTEXT] {Con{\TeX}t}
+\logo [CSS] {css}
+\logo [CTAN] {ctan}
+\logo [CTXTOOLS] {ctxtools}
+\logo [CWEB] {cweb}
+\logo [DANTE] {Dante}
+\logo [DISTILLER] {distiller}
+\logo [DRATEX] {Dra\TeX}
+\logo [DSC] {dsc}
+\logo [DTD] {dtd}
+\logo [DTK] {dtk}
+\logo [DTP] {dtp}
+\logo [DVD] {dvd}
+\logo [DVI] {dvi}
+\logo [DVIPDFM] {dvipdfm}
+\logo [DVIPDFMX] {dvipdfmx}
+\logo [DVIPOS] {dvipos}
+\logo [DVIPS] {dvips}
+\logo [DVIPSONE] {dvipsone}
+\logo [DVISCR] {dviscr}
+\logo [DVIWINDO] {dviwindo}
+\logo [EC] {ec}
+\logo [EIFFEL] {Eiffel}
+\logo [EMACS] {emacs}
+\logo [EMTEX] {em\TeX}
+\logo [ENCODING] {enc}
+\logo [ENCTEX] {enc\TeX}
+\logo [EPS] {eps}
+\logo [ETEX] {\eTeX}
+\logo [EUROBACHOTEX] {EuroBacho\TeX}
+\logo [EUROMATH] {EuroMath}
+\logo [EUROTEX] {Euro\TeX}
+\logo [EXAMPLE] {eXaMpLe}
+\logo [EXAMPLED] {exampled}
+\logo [EXAMPLEQ] {exampleq}
+\logo [EXAMPLER] {exampler}
+\logo [EXAMPLET] {examplet}
+\logo [EXAMPLEX] {examplex}
+\logo [EXIMPLE] {eXiMpLe}
+\logo [FAQ] {faq}
+\logo [FDF] {fdf}
+\logo [FONTFORGE] {FontForge}
+\logo [FOXET] {foXet}
+\logo [FPTEX] {fp\TeX}
+\logo [FREEBSD] {FreeBSD}
+\logo [FTP] {ftp}
+\logo [GHOSTSCRIPT]{Ghost\-script}
+\logo [GHOSTVIEW] {Ghost\-view}
+\logo [GIF] {gif}
+\logo [GNU] {gnu}
+\logo [GNUPLOT] {gnuplot}
+\logo [GS] {Ghost\-Script}
+\logo [GUST] {Gust}
+\logo [GWTEX] {gw\TeX}
+\logo [HSB] {hsb}
+\logo [HTML] {html}
+\logo [HTTP] {http}
+\logo [HZ] {hz}
+\logo [IBM] {ibm}
+\logo [IMAGEMAGICK]{ImageMagick}
+\logo [INITEX] {ini\TeX}
+\logo [INRSTEX] {inrs\TeX}
+\logo [IO] {io}
+\logo [IRCNET] {IRCnet}
+\logo [ISO] {iso}
+\logo [JAVA] {Java}
+\logo [JAVASCRIPT] {Java\-Script}
+\logo [JPEG] {jpeg}
+\logo [JPG] {jpg}
+\logo [JBIG] {jbig}
+\logo [KPATHSEA] {kpathsea}
+\logo [KPSE] {kpse}
+\logo [KPSEWHICH] {kpsewhich}
+\logo [MKTEXLSR] {mktexlsr}
+\logo [LAMSTEX] {LamS\TeX}
+\logo [LATEX] {La\TeX}
+\logo [LATEXTE] {La\TeX2e}
+\logo [LATEXTN] {La\TeX2.09}
+\logo [LINUX] {linux}
+\logo [LISP] {Lisp}
+\logo [LPEG] {lpeg}
+\logo [LUA] {Lua}
+\logo [LUAJIT] {LuaJIT}
+\logo [LUATEX] {Lua\TeX}
+\logo [LUAJITTEX] {Luajit\TeX}
+\logo [LUATOOLS] {luatools}
+\logo [MACOSX] {MacOSX}
+\logo [MACROTEX] {Macro\TeX}
+\logo [MAKEMPY] {MakeMPY}
+\logo [MAPPING] {map}
+\logo [MAPS] {Maps}
+\logo [MATHML] {MathML}
+\logo [METAFONT] {MetaFont}
+\logo [METAPOST] {MetaPost}
+\logo [METATEX] {Meta\TeX}
+\logo [MIKTEX] {Mik\TeX}
+\logo [MLTEX] {ml\TeX}
+\logo [METATYPE] {MetaType1}
+\logo [MODULA] {Modula}
+\logo [MOV] {mov}
+\logo [MPS] {mps}
+\logo [MPTOPDF] {mptopdf}
+\logo [MPLIB] {MPlib}
+\logo [MSDOS] {msdos}
+\logo [MSWINDOWS] {MS~Windows}
+\logo [MTXRUN] {mtxrun}
+\logo [MTXTOOLS] {mtxtools}
+\logo [NETPBM] {NetPBM}
+\logo [NTG] {ntg}
+\logo [NTS] {nts}
+\logo [OFM] {ofm}
+\logo [OMEGA] {Omega}
+\logo [OPENMATH] {OpenMath}
+\logo [OPENTYPE] {OpenType}
+\logo [OPI] {opi}
+\logo [OTF] {otf}
+\logo [OTP] {otp}
+\logo [OVF] {ovf}
+\logo [PASCAL] {Pascal}
+\logo [PCTEX] {pc\TeX}
+\logo [PDF] {pdf}
+\logo [PDFETEX] {pdfe\TeX}
+\logo [PDFTEX] {pdf\TeX}
+\logo [PDFTOOLS] {pdftools}
+\logo [PDFTOPS] {pdftops}
+\logo [PERL] {Perl}
+\logo [PERLTK] {Perl/Tk}
+\logo [PICTEX] {\PiCTeX}
+\logo [PK] {pk}
+\logo [PLAIN] {Plain}
+\logo [PNG] {png}
+\logo [POSIX] {posix}
+\logo [POSTSCRIPT] {Post\-Script}
+\logo [PPCHTEX] {\PPCHTeX}
+\logo [PRAGMA] {Pragma ADE}
+\logo [PRESS] {press}
+\logo [PRIFIL] {prifil}
+\logo [PS] {Post\-Script}
+\logo [PSCHECK] {pscheck}
+\logo [PSTOEDIT] {pstoedit}
+\logo [PSTOPAGE] {pstopage}
+\logo [PSTOPDF] {pstopdf}
+\logo [PSTRICKS] {pstricks}
+\logo [RAM] {ram}
+\logo [READER] {Acro\-bat Reader}
+\logo [RELAXNG] {Relax\kern.125emNG}
+\logo [RGB] {rgb}
+\logo [RLXTOOLS] {rlxtools}
+\logo [RUBY] {Ruby}
+\logo [SCITE] {SciTE}
+\logo [SGML] {sgml}
+\logo [SI] {si}
+\logo [SQL] {sql}
+\logo [TABLE] {\TaBlE}
+\logo [TCPIP] {tcp/ip}
+\logo [TDS] {tds} % no sc te
+\logo [TETEX] {te\TeX} % no sc te
+\logo [TEX] {\TeX}
+\logo [TEXADRES] {\TeX adress}
+\logo [TEXBASE] {\TeX base}
+\logo [TEXEDIT] {\TeX edit}
+\logo [TEXEXEC] {\TeX exec}
+\logo [TEXFONT] {\TeX font}
+\logo [TEXFORM] {\TeX form}
+\logo [TEXLIVE] {\TeX Live}
+\logo [TEXLUA] {\TeX Lua}
+\logo [TEXMF] {texmf}
+\logo [TEXMFSTART] {texmfstart}
+\logo [TEXNL] {tex-nl}
+\logo [TEXSHOW] {\TeX show}
+\logo [TEXSPELL] {\TeX spell}
+\logo [TEXGYRE] {\TeX\ Gyre}
+\logo [TEXSYNC] {texsync}
+\logo [TEXTMATE] {TextMate}
+\logo [TEXTOOLS] {\TeX tools}
+\logo [TEXUTIL] {\TeX util}
+\logo [TEXWORK] {\TeX work}
+\logo [TEXXET] {\TeX\XeT} \def\XeT{XeT}
+\logo [TFM] {tfm}
+\logo [TIF] {tif}
+\logo [TIFF] {tiff}
+\logo [TIFFINFO] {tiffinfo}
+\logo [TIFFTAGS] {tifftags}
+\logo [TMFTOOLS] {tmftools}
+\logo [TPIC] {tpic}
+\logo [TPM] {tpm}
+\logo [TRUETYPE] {TrueType}
+\logo [TTF] {ttf}
+\logo [TUG] {tug}
+\logo [TUGBOAT] {Tug\-Boat}
+\logo [TUGNEWS] {Tug\-News}
+\logo [TYPEONE] {Type1}
+\logo [UCS] {ucs}
+\logo [UNICODE] {Uni\-code}
+\logo [UNIX] {Unix}
+\logo [URI] {uri}
+\logo [URL] {url}
+\logo [USA] {usa}
+\logo [USENET] {usenet}
+\logo [UTF] {utf}
+\logo [UTF] {utf}
+\logo [VF] {vf}
+\logo [WDT] {wdt}
+\logo [WEB] {web}
+\logo [WEBC] {web2c}
+\logo [WIKI] {Wiki}
+\logo [WINDOWS] {Windows}
+\logo [WINNT] {WinNT}
+\logo [WINNX] {Win9x}
+\logo [WWW] {www}
+\logo [WYSIWYG] {wysiwyg}
+\logo [XDVI] {Xdvi}
+\logo [XETEX] {\XeTeX}
+\logo [XFDF] {xfdf}
+\logo [XHTML] {xhtml}
+\logo [XINDY] {Xindy}
+\logo [XML] {xml}
+\logo [XPATH] {xpath}
+\logo [XMLTOOLS] {xmltools}
+\logo [XPDFETEX] {xpdfe\TeX}
+\logo [XSL] {xsl}
+\logo [XSLFO] {xsl-fo}
+\logo [XSLT] {xslt}
+\logo [XSLTPROC] {xsltproc}
+\logo [XYPIC] {XYPIC} % wrong logo
+\logo [YandY] {y\&y}
+\logo [ZIP] {zip}
+
+\def\METAFUN {\MetaFun}
+
+\logo [METAFUN] {\MetaFun}
+
+\def\SystemSpecialA#1{$\langle\it#1\rangle$}
+\def\SystemSpecialB#1{{\tttf<#1>}}
+
+\def\CATCODE {\SystemSpecialA{catcode}}
+\def\CATCODES {\SystemSpecialA{catcodes}}
+\def\DIMENSION {\SystemSpecialA{dimension}}
+\def\DIMENSIONS {\SystemSpecialA{dimensions}}
+\def\COUNTER {\SystemSpecialA{counter}}
+\def\COUNTERS {\SystemSpecialA{counters}}
+\def\HBOX {\SystemSpecialA{hbox}}
+\def\HBOXES {\SystemSpecialA{hboxes}}
+\def\VBOX {\SystemSpecialA{vbox}}
+\def\VBOXES {\SystemSpecialA{vboxes}}
+\def\BOX {\SystemSpecialA{box}}
+\def\BOXES {\SystemSpecialA{boxes}}
+\def\TOKENLIST {\SystemSpecialA{token list}}
+\def\TOKENLISTS {\SystemSpecialA{token lists}}
+\def\NEWLINE {\SystemSpecialA{newline}}
+\def\SKIP {\SystemSpecialA{skip}}
+\def\SKIPS {\SystemSpecialA{skips}}
+\def\MUSKIP {\SystemSpecialA{muskip}}
+\def\MUSKIPS {\SystemSpecialA{muskips}}
+\def\MARK {\SystemSpecialA{mark}}
+\def\MARKS {\SystemSpecialA{marks}}
+
+\def\SPACE {\SystemSpecialB{space}}
+\def\EOF {\SystemSpecialB{eof}}
+\def\TAB {\SystemSpecialB{tab}}
+\def\NEWPAGE {\SystemSpecialB{newpage}}
+\def\NEWLINE {\SystemSpecialB{newline}}
+
+\def\THANH {H\`an Th\^e\llap{\raise 0.5ex\hbox{\'{}}} Th\`anh}
+
+\def\THANH {H\`an Th\ecircumflexacute\ Th\`anh}
+
+\endinput
diff --git a/tex/context/base/s-fonts-features.mkiv b/tex/context/base/s-fonts-features.mkiv
index b81b53a71..8982f7347 100644
--- a/tex/context/base/s-fonts-features.mkiv
+++ b/tex/context/base/s-fonts-features.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\startmodule[fonts-features]
+\startmodule[s-fonts-features]
\registerctxluafile{s-fonts-features}{}
diff --git a/tex/context/base/s-fonts-goodies.mkiv b/tex/context/base/s-fonts-goodies.mkiv
index e596507af..f07081825 100644
--- a/tex/context/base/s-fonts-goodies.mkiv
+++ b/tex/context/base/s-fonts-goodies.mkiv
@@ -13,7 +13,7 @@
%D More tables will follow here as we have many more goodies by now.
-\startmodule[fonts-goodies]
+\startmodule[s-fonts-goodies]
\registerctxluafile{s-fonts-goodies}{}
diff --git a/tex/context/base/s-fonts-missing.lua b/tex/context/base/s-fonts-missing.lua
index 9a75676a9..829fed45f 100644
--- a/tex/context/base/s-fonts-missing.lua
+++ b/tex/context/base/s-fonts-missing.lua
@@ -14,23 +14,33 @@ local function legend(id)
local privates = c.properties.privates
if privates then
local categories = table.swapped(fonts.loggers.category_to_placeholder)
- context.starttabulate { "|c|l|" }
+ -- context.starttabulate { "|l|c|c|l|" }
+ context.starttabulate { "|l|c|l|" }
context.HL()
context.NC()
+ context.bold("name")
+ context.NC()
context.bold("symbol")
context.NC()
- context.bold("name")
+ -- context.bold("node")
+ -- context.NC()
+ context.bold("category")
context.NC()
context.NR()
context.HL()
for k, v in table.sortedhash(privates) do
local tag = characters.categorytags[categories[k]]
if tag and tag ~= "" then
+ context.NC()
+ context(k)
context.NC()
context.dontleavehmode()
context.char(v)
context.NC()
- context(k)
+ -- context.dontleavehmode()
+ -- commands.getprivatechar(k)
+ -- context.NC()
+ context(string.lower(tag))
context.NC()
context.NR()
end
diff --git a/tex/context/base/s-fonts-missing.mkiv b/tex/context/base/s-fonts-missing.mkiv
index c566f4995..6acef819e 100644
--- a/tex/context/base/s-fonts-missing.mkiv
+++ b/tex/context/base/s-fonts-missing.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\startmodule[fonts-missing]
+\startmodule[s-fonts-missing]
\registerctxluafile{s-fonts-missing}{}
diff --git a/tex/context/base/s-fonts-shapes.mkiv b/tex/context/base/s-fonts-shapes.mkiv
index f8eb8ffdd..56e3d80a7 100644
--- a/tex/context/base/s-fonts-shapes.mkiv
+++ b/tex/context/base/s-fonts-shapes.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\startmodule[fonts-shapes]
+\startmodule[s-fonts-shapes]
\registerctxluafile{s-fonts-shapes}{}
diff --git a/tex/context/base/s-fonts-tables.mkiv b/tex/context/base/s-fonts-tables.mkiv
index e962f952d..98f9052ca 100644
--- a/tex/context/base/s-fonts-tables.mkiv
+++ b/tex/context/base/s-fonts-tables.mkiv
@@ -13,7 +13,7 @@
% todo: make a mtxrun --script font option
-\startmodule[fonts-tables]
+\startmodule[s-fonts-tables]
\registerctxluafile{s-fonts-tables}{}
diff --git a/tex/context/base/s-fonts-vectors.lua b/tex/context/base/s-fonts-vectors.lua
index af8042f84..1bac0ae8b 100644
--- a/tex/context/base/s-fonts-vectors.lua
+++ b/tex/context/base/s-fonts-vectors.lua
@@ -20,7 +20,7 @@ function moduledata.fonts.protrusions.showvector(specification)
local vector = vectors[specification.name or "?"]
if vector then
context.blank()
- context.startcolumns { n = specification.columns or 3, balance="yes" }
+ context.startcolumns { n = specification.columns or 3 }
context.starttabulate { "|T||cw(.5em)||" }
for unicode, values in table.sortedhash(vector) do
NC() context("%U",unicode)
@@ -65,7 +65,7 @@ function moduledata.fonts.expansions.showvector(specification)
local vector = vectors[specification.name or "?"]
if vector then
context.blank()
- context.startcolumns { n = specification.columns or 3, balance="yes" }
+ context.startcolumns { n = specification.columns or 3 }
context.starttabulate { "|T|cw(.5em)||" }
for unicode, value in table.sortedhash(vector) do
NC() context("%U",unicode)
diff --git a/tex/context/base/s-fonts-vectors.mkiv b/tex/context/base/s-fonts-vectors.mkiv
index 2605fe964..371a30cc5 100644
--- a/tex/context/base/s-fonts-vectors.mkiv
+++ b/tex/context/base/s-fonts-vectors.mkiv
@@ -13,7 +13,7 @@
%D This code is used in the \MKIV\ fonts manual.
-\startmodule[fonts-vectors]
+\startmodule[s-fonts-vectors]
\registerctxluafile{s-fonts-vectors}{}
diff --git a/tex/context/base/s-math-coverage.lua b/tex/context/base/s-math-coverage.lua
index a74e24450..258019c9d 100644
--- a/tex/context/base/s-math-coverage.lua
+++ b/tex/context/base/s-math-coverage.lua
@@ -77,8 +77,6 @@ local chardata = characters.data
local superscripts = characters.superscripts
local subscripts = characters.subscripts
-context.writestatus("math coverage","underline: not remapped")
-
function moduledata.math.coverage.showalphabets()
context.starttabulate { "|lT|l|Tl|" }
for i=1,#styles do
diff --git a/tex/context/base/s-present-tiles.mkiv b/tex/context/base/s-present-tiles.mkiv
index b68a34ef4..80ea5249f 100644
--- a/tex/context/base/s-present-tiles.mkiv
+++ b/tex/context/base/s-present-tiles.mkiv
@@ -13,7 +13,7 @@
%D The Bacho\TeX\ 2013 style.
-\setupbodyfont[pagella,14.4pt]
+\setupbodyfont[palatino,14.4pt]
\setuppapersize[S6][S6]
@@ -64,22 +64,8 @@
-\topspace
]
-\definemeasure [topiclistfontsize] [
- \ifcase\numexpr\structurelistsize\relax 2.5 % 0
- \or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4\or1.4 % 1 - 9
- \or1.3\or1.3\or1.3\or1.3\or1.3\or1.3\or1.3 % 10 - 16
- \or1.2\or1.2\or1.2\or1.2\or1.2 % 17 - 20
- \else1 % 21 - 25
- \fi
- \bodyfontsize
-]
-
-\definemeasure [topiclistfont] [\measured{topiclistfontsize}]
-\definemeasure [topictitlefont] [1.2\measured{layoutunit}]
-\definemeasure [titlepagefont] [2\measured{layoutunit}]
-
-\predefinefont[MyTopicTitleFont][SerifBold*default at \measure{topictitlefont}]
-\predefinefont[MyTopicListFont] [SerifBold*default at \measure{topiclistfont}]
+\definemeasure [topiclistfont] [\measured{topiclistwidth}/10]
+\definemeasure [titlepagefont] [2\measured{layoutunit}]
\defineframed
[topiclistentry]
@@ -87,7 +73,7 @@
height=\measure{topiclistheight},
background=color,
frame=off,
- foregroundstyle=MyTopicListFont,
+ foregroundstyle={\definedfont[Bold at \measure{topiclistfont}]},
backgroundcolor=primarycolor,
foregroundcolor=white]
@@ -122,6 +108,8 @@
\stoptopicmakeup
\stopsetups
+\predefinefont[MyTopicTitleFont][SerifBold*default at \measure{layoutunit}]
+
\definehead
[topic]
[chapter]
@@ -228,15 +216,6 @@
% end of buttons
-\defineframed
- [conclusion]
- [location=low,
- width=max,
- align={flushleft,lohi},
- background=color,
- backgroundcolor=white,
- foregroundcolor=secondarycolor]
-
\startsetups [document:titlepage]
\definebodyfontenvironment
diff --git a/tex/context/base/s-sql-tables.mkiv b/tex/context/base/s-sql-tables.mkiv
index 122570874..6f507e8b5 100644
--- a/tex/context/base/s-sql-tables.mkiv
+++ b/tex/context/base/s-sql-tables.mkiv
@@ -13,7 +13,7 @@
% for the moment no helpers
-\startmodule[sql-tables]
+\startmodule[s-sql-tables]
\registerctxluafile{s-sql-tables}{}
diff --git a/tex/context/base/scrn-but.lua b/tex/context/base/scrn-but.lua
index 74f6e0cd9..e49372ce9 100644
--- a/tex/context/base/scrn-but.lua
+++ b/tex/context/base/scrn-but.lua
@@ -6,9 +6,6 @@ if not modules then modules = { } end modules ['scrn-but'] = {
license = "see context related readme files"
}
-local commands = commands
-local context = context
-
local f_two_colon = string.formatters["%s:%s"]
function commands.registerbuttons(tag,register,language)
diff --git a/tex/context/base/scrn-fld.lua b/tex/context/base/scrn-fld.lua
index 69480b887..9836cbebe 100644
--- a/tex/context/base/scrn-fld.lua
+++ b/tex/context/base/scrn-fld.lua
@@ -11,8 +11,6 @@ if not modules then modules = { } end modules ['scrn-fld'] = {
local variables = interfaces.variables
local v_yes = variables.yes
-local texsetbox = tex.setbox
-
local fields = { }
interactions.fields = fields
@@ -45,7 +43,7 @@ commands.definefieldset = defineset
commands.clonefield = clone
function commands.insertfield(name,specification)
- texsetbox("b_scrn_field_body",insert(name,specification))
+ tex.box["b_scrn_field_body"] = insert(name,specification)
end
-- (for the monent) only tex interface
diff --git a/tex/context/base/scrn-hlp.lua b/tex/context/base/scrn-hlp.lua
index d344ce280..5f8368c6d 100644
--- a/tex/context/base/scrn-hlp.lua
+++ b/tex/context/base/scrn-hlp.lua
@@ -11,9 +11,6 @@ local format = string.format
local help = { }
interactions.help = help
-local context = context
-local commands = commands
-
local a_help = attributes.private("help")
local copy_nodelist = node.copy_list
@@ -21,8 +18,6 @@ local hpack_nodelist = node.hpack
local register_list = nodes.pool.register
-local texgetbox = tex.getbox
-
local nodecodes = nodes.nodecodes
local hlist_code = nodecodes.hlist
@@ -53,7 +48,7 @@ function help.register(number,name,box)
interactions.javascripts.setpreamble("HelpTexts",helpscript)
helpscript = false
end
- local b = copy_nodelist(texgetbox(box))
+ local b = copy_nodelist(tex.box[box])
register_list(b)
data[number] = b
if name and name ~= "" then
@@ -86,7 +81,7 @@ end
function help.collect(box)
if next(data) then
- return collect(texgetbox(box).list)
+ return collect(tex.box[box].list)
end
end
diff --git a/tex/context/base/scrn-wid.lua b/tex/context/base/scrn-wid.lua
index 5b319b07e..4ad46761e 100644
--- a/tex/context/base/scrn-wid.lua
+++ b/tex/context/base/scrn-wid.lua
@@ -9,27 +9,19 @@ if not modules then modules = { } end modules ['scrn-wid'] = {
interactions = interactions or { }
local interactions = interactions
-local context = context
-
-local allocate = utilities.storage.allocate
-
-local attachments = allocate()
-local comments = allocate()
-local soundclips = allocate()
-local renderings = allocate()
-local linkedlists = allocate()
+local attachments = { }
+local comments = { }
+local soundclips = { }
+local renderings = { }
+local linkedlists = { }
interactions.attachments = attachments
interactions.soundclips = soundclips
interactions.renderings = renderings
interactions.linkedlists = linkedlists
-local texsetbox = tex.setbox
-
local jobpasses = job.passes
-local texgetcount = tex.getcount
-
local codeinjections = backends.codeinjections
local nodeinjections = backends.nodeinjections
@@ -111,7 +103,7 @@ end
commands.registerattachment = attachments.register
function commands.insertattachment(specification)
- texsetbox("b_scrn_attachment_link",(attachments.insert(specification)))
+ tex.box["b_scrn_attachment_link"] = attachments.insert(specification)
end
-- Comment
@@ -125,7 +117,7 @@ function comments.insert(specification)
end
function commands.insertcomment(specification)
- texsetbox("b_scrn_comment_link",(comments.insert(specification)))
+ tex.box["b_scrn_comment_link"] = comments.insert(specification)
end
-- Soundclips
@@ -203,7 +195,7 @@ end
function commands.enhancelinkedlist(tag,n)
local ll = jobpasses.gettobesaved(tag)
if ll then
- ll[n] = texgetcount("realpageno")
+ ll[n] = texcount.realpageno
end
end
diff --git a/tex/context/base/scrn-wid.mkvi b/tex/context/base/scrn-wid.mkvi
index fad451651..ae5f7c556 100644
--- a/tex/context/base/scrn-wid.mkvi
+++ b/tex/context/base/scrn-wid.mkvi
@@ -16,7 +16,6 @@
\registerctxluafile{scrn-wid}{1.001}
% todo: expansion in comments (default is expanded)
-% todo: check renderings ... acrobat crashes too easily on missing one
\unprotect
@@ -567,8 +566,8 @@
\definereference[PauseCurrentRendering] [\v!PauseRendering {\currentrendering}]
\definereference[ResumeCurrentRendering][\v!ResumeRendering{\currentrendering}]
-\unexpanded\def\useexternalrendering{\doquadrupleempty\scrn_rendering_use}
-\unexpanded\def\setinternalrendering{\dodoubleempty \scrn_rendering_set}
+\def\useexternalrendering{\doquadrupleempty\scrn_rendering_use}
+\def\setinternalrendering{\dodoubleempty \scrn_rendering_set}
\def\scrn_rendering_use[#tag][#mime][#file][#option]%
{\ctxcommand{registerrendering{
@@ -579,7 +578,7 @@
option = "#option",
}}}
-\def\scrn_rendering_set[#tag][#option]% {content} % crappy
+\def\scrn_rendering_set[#tag][#option]% {content}
{\bgroup
\dowithnextbox
{\ctxcommand{registerrendering{
@@ -616,9 +615,17 @@
\unexpanded\def\placerenderingwindow
{\dodoubleempty\scrn_rendering_place_window}
-\def\scrn_rendering_place_window[#window][#rendering]% do all in lua
+\def\scrn_rendering_place_window[#window][#rendering]%
{\bgroup
\edef\currentrendering{\ifsecondargument#rendering\else#window\fi}%
+ \doifelse{\renderingtype\currentrendering}{internal} % an object
+ {\getobjectdimensions{IRO}\currentrendering
+ \d_scrn_rendering_height\dimexpr\objectheight+\objectdepth\relax
+ \d_scrn_rendering_width\objectwidth\relax
+ \dogetobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page}%
+ {\d_scrn_rendering_height\vsize
+ \d_scrn_rendering_width\hsize
+ \let\m_scrn_rendering_page\realpageno}%
% create fall back if needed
\edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}% stupid test, we need a proper one here
\ifx\currentrenderingwindow\empty
@@ -627,21 +634,6 @@
\else
\edef\currentrenderingwindow{#window}%
\fi
- \edef\currentrenderingtype{\renderingtype\currentrendering}%
- \ifx\currentrenderingtype\s!internal
- \getobjectdimensions{IRO}\currentrendering
- \d_scrn_rendering_height\dimexpr\objectheight+\objectdepth\relax
- \d_scrn_rendering_width\objectwidth\relax
- \dogetobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page
- \else\ifx\currentrenderingwindow\s!default
- \d_scrn_rendering_height\vsize
- \d_scrn_rendering_width \hsize
- \let\m_scrn_rendering_page\realpageno
- \else
- \d_scrn_rendering_height\renderingwindowparameter\c!height
- \d_scrn_rendering_width \renderingwindowparameter\c!width
- \let\m_scrn_rendering_page\realpageno
- \fi\fi
% todo:
% \handlereferenceactions{\renderingwindowparameter\c!openpageaction }\dosetuprenderingopenpageaction
% \handlereferenceactions{\renderingwindowparameter\c!closepageaction}\dosetuprenderingclosepageaction
diff --git a/tex/context/base/scrp-ini.lua b/tex/context/base/scrp-ini.lua
index 56422e622..18f86475f 100644
--- a/tex/context/base/scrp-ini.lua
+++ b/tex/context/base/scrp-ini.lua
@@ -11,16 +11,12 @@ if not modules then modules = { } end modules ['scrp-ini'] = {
local attributes, nodes, node = attributes, nodes, node
-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)
-local trace_splitting = false trackers.register("scripts.splitting", function(v) trace_splitting = v end)
-local trace_splitdetail = false trackers.register("scripts.splitring.detail", function(v) trace_splitdetail = v end)
+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)
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 utfchar = utf.char
local first_glyph = node.first_glyph or node.first_character
local traverse_id = node.traverse_id
@@ -33,9 +29,6 @@ local unsetvalue = attributes.unsetvalue
local glyph_code = nodecodes.glyph
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')
@@ -48,14 +41,6 @@ local setmetatableindex = table.setmetatableindex
local enableaction = nodes.tasks.enableaction
local disableaction = nodes.tasks.disableaction
-local insert_node_after = node.insert_after
-
-local nodepool = nodes.pool
-local new_glue = nodepool.glue
-local new_rule = nodepool.rule
-local new_penalty = nodepool.penalty
------ new_gluespec = nodepool.gluespec
-
scripts = scripts or { }
local scripts = scripts
@@ -213,7 +198,7 @@ local function provide(t,k)
return v
end
-setmetatableindex(hash,provide) -- should come from char-def
+setmetatableindex(hash,provide)
scripts.hash = hash
@@ -557,289 +542,10 @@ function scripts.injectors.handler(head)
end
end
--- kind of experimental .. might move to it's own module
-
--- function scripts.splitters.handler(head)
--- return head, false
--- end
-
-local function addwords(tree,data)
- if not tree then
- tree = { }
- end
- for word in gmatch(data,"%S+") do
- local root = tree
- local list = utfsplit(word,true)
- for i=1,#list do
- local l = utfbyte(list[i])
- local r = root[l]
- if not r then
- r = { }
- root[l] = r
- end
- if i == #list then
- r.final = word -- true -- could be something else, like word in case of tracing
- else
- root = r
- end
- end
- end
- return tree
-end
-
-local loaded = { }
-
-function splitters.load(handler,files)
- local files = handler.files
- local tree = handler.tree or { }
- handler.tree = tree
- if not files then
- return
- elseif type(files) == "string" then
- files = { files }
- handler.files = files
- end
- if trace_splitting then
- report_splitting("loading splitter data for language/script %a",handler.name)
- end
- loaded[handler.name or "unknown"] = (loaded[handler.name or "unknown"] or 0) + 1
- statistics.starttiming(loaded)
- for i=1,#files do
- local filename = files[i]
- local fullname = resolvers.findfile(filename)
- if fullname == "" then
- fullname = resolvers.findfile(filename .. ".gz")
- end
- if fullname ~= "" then
- if trace_splitting then
- report_splitting("loading file %a",fullname)
- end
- local suffix, gzipped = gzip.suffix(fullname)
- if suffix == "lua" then
- local specification = table.load(fullname,gzipped and gzip.load)
- if specification then
- local lists = specification.lists
- if lists then
- for i=1,#lists do
- local entry = lists[i]
- local data = entry.data
- if data then
- if entry.compression == "zlib" then
- data = zlib.decompress(data)
- if entry.length and entry.length ~= #data then
- report_splitting("compression error in file %a",fullname)
- end
- end
- if data then
- addwords(tree,data)
- end
- end
- end
- end
- end
- else
- local data = gzipped and io.loadgzip(fullname) or io.loaddata(fullname)
- if data then
- addwords(tree,data)
- end
- end
- else
- report_splitting("unknown file %a",filename)
- end
- end
- statistics.stoptiming(loaded)
- return tree
-end
-
-statistics.register("loaded split lists", function()
- if next(loaded) then
- return string.format("%s, load time: %s",table.sequenced(loaded),statistics.elapsedtime(loaded))
- end
-end)
-
--- function splitters.addlist(name,filename)
--- local handler = scripts.handlers[name]
--- if handler and filename then
--- local files = handler.files
--- if not files then
--- files = { }
--- elseif type(files) == "string" then
--- files = { files }
--- end
--- handler.files = files
--- if type(filename) == "string" then
--- filename = utilities.parsers.settings_to_array(filename)
--- end
--- if type(filename) == "table" then
--- for i=1,#filename do
--- files[#files+1] = filenames[i]
--- end
--- end
--- end
--- end
---
--- commands.setscriptsplitterlist = splitters.addlist
-
-local categories = characters.categories or { }
-
-local function hit(root,head)
- local current = head.next
- local lastrun = false
- local lastfinal = false
- while current and current.id == glyph_code do
- local char = current.char
- local newroot = root[char]
- if newroot then
- local final = newroot.final
- if final then
- lastrun = current
- lastfinal = final
- end
- root = newroot
- elseif categories[char] == "mn" then
- -- continue
- else
- return lastrun, lastfinal
- end
- current = current.next
- end
- if lastrun then
- return lastrun, lastfinal
- end
+function scripts.splitters.handler(head)
+ return head, false
end
-local tree, attr, proc
-
-function splitters.handler(head)
- local current = head
- local done = false
- while current do
- if current.id == glyph_code then
- local a = current[a_scriptsplitting]
- if a then
- if a ~= attr then
- local handler = numbertohandler[a]
- tree = handler.tree or { }
- attr = a
- proc = handler.splitter
- end
- if proc then
- local root = tree[current.char]
- if root then
- -- we don't check for attributes in the hitter (yet)
- local last, final = hit(root,current)
- if last then
- local next = last.next
- if next and next.id == glyph_code then
- local nextchar = next.char
- if tree[nextchar] then
- if trace_splitdetail then
- if type(final) == "string" then
- report_splitting("advance %s processing between <%s> and <%c>","with",final,nextchar)
- else
- report_splitting("advance %s processing between <%c> and <%c>","with",char,nextchar)
- end
- end
- head, current = proc(handler,head,current,last,1)
- done = true
- else
- if trace_splitdetail then
- -- could be punctuation
- if type(final) == "string" then
- report_splitting("advance %s processing between <%s> and <%c>","without",final,nextchar)
- else
- report_splitting("advance %s processing between <%c> and <%c>","without",char,nextchar)
- end
- end
- head, current = proc(handler,head,current,last,2)
- done = true
- end
- end
- end
- end
- end
- end
- end
- current = current.next
- end
- return head, done
-end
-
-local function marker(head,current,font,color) -- could become: nodes.tracers.marker
- local ex = exheights[font]
- local em = emwidths [font]
- head, current = insert_node_after(head,current,new_penalty(10000))
- head, current = insert_node_after(head,current,new_glue(-0.05*em))
- head, current = insert_node_after(head,current,new_rule(0.05*em,1.5*ex,0.5*ex))
- setnodecolor(current,color)
- return head, current
-end
-
--- local function process(handler,head,first,last)
--- dataset = numbertodataset[first[a_scriptsplitting]]
--- stretch = emwidths[first.font]*dataset.inter_word_stretch_factor
--- return insert_node_after(head,last,new_glue(0,stretch))
--- end
---
--- local cache = { } table.setmetatableindex(cache,function(t,k)
--- local v = new_gluespec(0,k)
--- nodepool.register(v)
--- t[k] = v
--- return v
--- end)
--- return insert_node_after(head,last,new_glue(cache[last_s]))
-
-local last_a, last_f, last_s, last_q
-
-function splitters.insertafter(handler,head,first,last,detail)
- local a = first[a_scriptsplitting]
- local f = first.font
- if a ~= last_a or f ~= last_f then
- last_s = emwidths[f] * numbertodataset[a].inter_word_stretch_factor
- last_a = a
- last_f = f
- end
- if trace_splitting then
- head, last = marker(head,last,f,detail == 2 and "trace:r" or "trace:g")
- end
- if ignore then
- return head, last
- else
- return insert_node_after(head,last,new_glue(0,last_s))
- end
-end
-
--- word-xx.lua:
---
--- return {
--- comment = "test",
--- copyright = "not relevant",
--- language = "en",
--- timestamp = "2013-05-20 14:15:21",
--- version = "1.00",
--- lists = {
--- {
--- -- data = "we thrive information in thick worlds because of our marvelous and everyday capacity to select edit single out structure highlight group pair merge harmonize synthesize focus organize condense reduce boil down choose categorize catalog classify list abstract scan look into idealize isolate discriminate distinguish screen pigeonhole pick over sort integrate blend inspect filter lump skip smooth chunk average approximate cluster aggregate outline summarize itemize review dip into flip through browse glance into leaf through skim refine enumerate glean synopsize winnow the wheat from the chaff and separate the sheep from the goats",
--- data = "abstract aggregate and approximate average because blend boil browse capacity catalog categorize chaff choose chunk classify cluster condense dip discriminate distinguish down edit enumerate everyday filter flip focus from glance glean goats group harmonize highlight idealize in information inspect integrate into isolate itemize leaf list look lump marvelous merge of organize our out outline over pair pick pigeonhole reduce refine review scan screen select separate sheep single skim skip smooth sort structure summarize synopsize synthesize the thick thrive through to we wheat winnow worlds",
--- },
--- },
--- }
-
-scripts.installmethod {
- name = "test",
- splitter = splitters.insertafter,
- initializer = splitters.load,
- files = {
- -- "scrp-imp-word-test.lua",
- "word-xx.lua",
- },
- datasets = {
- default = {
- inter_word_stretch_factor = 0.25, -- of quad
- },
- },
-}
-
-- new plugin:
local registercontext = fonts.specifiers.registercontext
diff --git a/tex/context/base/scrp-ini.mkiv b/tex/context/base/scrp-ini.mkiv
index 4a27dd8e2..fe62295bb 100644
--- a/tex/context/base/scrp-ini.mkiv
+++ b/tex/context/base/scrp-ini.mkiv
@@ -16,7 +16,6 @@
\registerctxluafile{scrp-ini}{1.001}
\registerctxluafile{scrp-cjk}{1.001}
\registerctxluafile{scrp-eth}{1.001}
-\registerctxluafile{scrp-tha}{1.001}
\definesystemattribute[scriptinjection][public]
\definesystemattribute[scriptsplitting][public]
diff --git a/tex/context/base/scrp-tha.lua b/tex/context/base/scrp-tha.lua
deleted file mode 100644
index ec5df07c0..000000000
--- a/tex/context/base/scrp-tha.lua
+++ /dev/null
@@ -1,57 +0,0 @@
-if not modules then modules = { } end modules ['scrp-tha'] = {
- version = 1.001,
- comment = "companion to scrp-ini.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
--- This module needs dictionary files that looks as follows. At some point
--- we will add these files to the distribution.
---
--- word-th.lua:
---
--- return {
--- comment = "The data is taken from http://thailinux.gits.net.th/websvn/wsvn/software.swath by Phaisarn Charoenpornsawat and Theppitak Karoonboonyanan.",
--- copyright = "gnu general public license",
--- language = "th",
--- compiling = "mtxrun --script patterns --words --update --compress word-th.lua",
--- timestamp = "0000-00-00 00:00:00",
--- version = "1.00",
--- lists = {
--- { filename = "tdict-city.txt" },
--- { filename = "tdict-collection.txt" },
--- { filename = "tdict-common.txt" },
--- { filename = "tdict-country.txt" },
--- { filename = "tdict-district.txt" },
--- { filename = "tdict-geo.txt" },
--- { filename = "tdict-history.txt" },
--- { filename = "tdict-ict.txt" },
--- { filename = "tdict-lang-ethnic.txt" },
--- { filename = "tdict-proper.txt" },
--- { filename = "tdict-science.txt" },
--- { filename = "tdict-spell.txt" },
--- { filename = "tdict-std-compound.txt" },
--- { filename = "tdict-std.txt" },
--- },
--- }
-
--- Currently there is nothing additional special here, first we need a
--- ConTeXt user who uses it. It's a starting point.
-
-local splitters = scripts.splitters
-
-scripts.installmethod {
- name = "thai",
- splitter = splitters.insertafter,
- initializer = splitters.load,
- files = {
- -- "scrp-imp-word-thai.lua",
- "word-th.lua",
- },
- datasets = {
- default = {
- inter_word_stretch_factor = 0.25, -- of quad
- },
- },
-}
diff --git a/tex/context/base/sort-lan.lua b/tex/context/base/sort-lan.lua
index 8efc0924a..d2fa276d7 100644
--- a/tex/context/base/sort-lan.lua
+++ b/tex/context/base/sort-lan.lua
@@ -9,7 +9,6 @@ if not modules then modules = { } end modules ['sort-lan'] = {
-- todo: look into uts#10 (2012) ... some experiments ... something
-- 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
diff --git a/tex/context/base/spac-ali.lua b/tex/context/base/spac-ali.lua
index 25cc6cd66..ceb278433 100644
--- a/tex/context/base/spac-ali.lua
+++ b/tex/context/base/spac-ali.lua
@@ -20,6 +20,8 @@ local hpack_nodes = node.hpack -- nodes.fasthpack not really faster here
local unsetvalue = attributes.unsetvalue
+local concat_nodes = nodes.concat
+
local nodecodes = nodes.nodecodes
local listcodes = nodes.listcodes
@@ -33,8 +35,8 @@ local new_stretch = nodepool.stretch
local a_realign = attributes.private("realign")
-local texsetattribute = tex.setattribute
-local texgetcount = tex.getcount
+local texattribute = tex.attribute
+local texcount = tex.count
local isleftpage = layouts.status.isleftpage
@@ -75,12 +77,12 @@ local function handler(head,leftpage,realpageno)
action = leftpage and 2 or 1
end
if action == 1 then
- current.list = hpack_nodes(current.list .. new_stretch(3),current.width,"exactly")
+ current.list = hpack_nodes(concat_nodes{current.list,new_stretch(3)},current.width,"exactly")
if trace_realign then
report_realign("flushing left, align %a, page %a, realpage %a",align,pageno,realpageno)
end
elseif action == 2 then
- current.list = hpack_nodes(new_stretch(3) .. current.list,current.width,"exactly")
+ current.list = hpack_nodes(concat_nodes{new_stretch(3),current.list},current.width,"exactly")
if trace_realign then
report_realign("flushing right. align %a, page %a, realpage %a",align,pageno,realpageno)
end
@@ -104,7 +106,7 @@ end
function alignments.handler(head)
local leftpage = isleftpage(true,false)
- local realpageno = texgetcount("realpageno")
+ local realpageno = texcount.realpageno
return handler(head,leftpage,realpageno)
end
@@ -118,7 +120,7 @@ function alignments.set(n)
report_realign("enabled")
end
end
- texsetattribute(a_realign,texgetcount("realpageno") * 10 + n)
+ texattribute[a_realign] = texcount.realpageno * 10 + n
end
commands.setrealign = alignments.set
diff --git a/tex/context/base/spac-ali.mkiv b/tex/context/base/spac-ali.mkiv
index a7ce5b971..0f9b21186 100644
--- a/tex/context/base/spac-ali.mkiv
+++ b/tex/context/base/spac-ali.mkiv
@@ -149,17 +149,6 @@
inline:\ifconditional \inlinelefttoright l2r\else r2l\fi\space
]\endgroup}
-\unexpanded\def\righttolefthbox#1#{\normalhbox dir TRT #1\bgroup\righttoleft\let\next} \let\rtlhbox\righttolefthbox
-\unexpanded\def\lefttorighthbox#1#{\normalhbox dir TLT #1\bgroup\lefttoright\let\next} \let\ltrhbox\lefttorighthbox
-\unexpanded\def\righttoleftvbox#1#{\normalvbox dir TRT #1\bgroup\righttoleft\let\next} \let\rtlvbox\righttoleftvbox
-\unexpanded\def\lefttorightvbox#1#{\normalvbox dir TLT #1\bgroup\lefttoright\let\next} \let\ltrvbox\lefttorightvbox
-\unexpanded\def\righttoleftvtop#1#{\normalvtop dir TRT #1\bgroup\righttoleft\let\next} \let\rtlvtop\righttoleftvtop
-\unexpanded\def\lefttorightvtop#1#{\normalvtop dir TLT #1\bgroup\lefttoright\let\next} \let\ltrvtop\lefttorightvtop
-
-\unexpanded\def\autodirhbox#1#{\hbox#1\bgroup\synchronizeinlinedirection\let\next}
-\unexpanded\def\autodirvbox#1#{\vbox#1\bgroup\synchronizeinlinedirection\let\next} % maybe also pardir or maybe just a \vbox
-\unexpanded\def\autodirvtop#1#{\vtop#1\bgroup\synchronizeinlinedirection\let\next} % maybe also pardir or maybe just a \vtop
-
% Tolerance and hyphenation
\ifdefined\lesshyphens \else \let\lesshyphens\relax \fi
@@ -564,20 +553,6 @@
\fi
\raggedcommand}
-% experiment
-
-\unexpanded\def\spac_align_use_later#1%
- {\begingroup
- \edef\m_spac_align_asked{#1}%
- \expandafter\let\expandafter\raggedcommand\csname\??alignmentnormalcache\m_spac_align_asked\endcsname
- \ifx\raggedcommand\relax
- \spac_align_add_to_cache
- \fi
- \endgroup}
-
-\unexpanded\def\spac_align_use_now#1%
- {\csname\??alignmentnormalcache#1\endcsname}
-
% The keywords:
\unexpanded\def\installalign#1#2% beware: commands must be unexpandable!
diff --git a/tex/context/base/spac-cha.mkiv b/tex/context/base/spac-cha.mkiv
new file mode 100644
index 000000000..a07c8f198
--- /dev/null
+++ b/tex/context/base/spac-cha.mkiv
@@ -0,0 +1,191 @@
+%D \module
+%D [ file=spac-cha, % was supp-ali,
+%D version=2012.06.08, % 2000.04.17,
+%D title=\CONTEXT\ Spacing Macros,
+%D subtitle=Character Alignment,
+%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 Yet undocumented but nevertheless used.
+
+% 0 = centered
+% 1 = left in before
+% 2 = right in before
+% 3 = left in after
+% 4 = right in after
+
+\unprotect
+
+% \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 100,00 \NG 100,00 \NG 10,00 \NC\NR
+% \NG 10\\ \NG 10\\ \NG 0,00 \NC\NR
+% \NG 10 \NG 10 \NG 0,00 \NC\NR
+% \NG 10 \NG 10 \NG 0,00 \NC\NR
+% \stoptabulate
+
+% We gain not much by luafication and actually make things worse.
+
+\chardef\characteralignmentmode\plusfour
+\chardef\characteralignmentslot\plusone
+
+\let\afterassignwidth \!!zeropoint
+\let\beforeassignwidth\!!zeropoint
+
+\def\alignmentcharacter{.}
+
+\newdimen\d_supp_charalign_width
+\newtoks \t_supp_charalign_list
+
+\let\alignmentclass\s!default % can be used to handle multiple mixed ones
+
+\installcorenamespace{characteralign}
+
+\unexpanded\def\supp_charalign_push
+ {\ifcsname\??characteralign\alignmentclass\endcsname\else
+ \normalexpanded{\global\t_supp_charalign_list{\the\t_supp_charalign_list\supp_charalign_do{\alignmentclass}}}%
+ \fi
+ \setxvalue{\??characteralign\alignmentclass}{\supp_charalign_do
+ {\afterassignwidth}{\beforeassignwidth}{\alignmentcharacter}}}
+
+\unexpanded\def\supp_charalign_pop_do#1#2#3%
+ {\def\afterassignwidth {#1}%
+ \def\beforeassignwidth {#2}%
+ \def\alignmentcharacter{#3}}
+
+\unexpanded\def\supp_charalign_pop
+ {\let\supp_charalign_do\supp_charalign_pop_do
+ \executeifdefined{\??characteralign\alignmentclass}\donothing}
+
+\unexpanded\def\supp_charalign_reset_do#1%
+ {\global\letbeundefined{\??characteralign#1}} % global !
+
+\unexpanded\def\resetcharacteralign
+ {\let\supp_charalign_do\supp_charalign_reset_do
+ \the\t_supp_charalign_list
+ \global\t_supp_charalign_list\emptytoks}
+
+\unexpanded\def\supp_charalign_firstpass_one#1#2%
+ {\supp_charalign_pop
+ \let\\\empty
+ \setbox\scratchbox\hbox{#1}%
+ \d_supp_charalign_width\wd\scratchbox
+ \setbox\scratchbox\emptyhbox
+ \supp_charalign_check#2#1\relax\relax
+ \scratchdimen-\wd\scratchbox
+ \setbox\scratchbox\hbox{\ignorespaces#2\unskip}%
+ \advance\scratchdimen \wd\scratchbox
+ \ifdim\scratchdimen>\beforeassignwidth\relax
+ \edef\beforeassignwidth{\the\scratchdimen}%
+ \fi
+ \ifdim\scratchdimen=\zeropoint
+ \setbox\scratchbox\hbox{\ignorespaces#2\unskip}%
+ \scratchdimen\wd\scratchbox
+ \ifcase\characteralignmentmode
+ % do nothing
+ \else\ifnum\characteralignmentmode<\plusthree
+ \advance\scratchdimen\d_supp_charalign_width\relax
+ \ifdim\scratchdimen>\beforeassignwidth\relax
+ \edef\beforeassignwidth{\the\scratchdimen}%
+ \fi
+ \else
+ \ifdim\scratchdimen>\afterassignwidth\relax
+ \edef\afterassignwidth{\the\scratchdimen}%
+ \fi
+ \fi\fi
+ \fi
+ \supp_charalign_push}
+
+\unexpanded\def\supp_charalign_firstpass_two#1#2#3%
+ {\ifx#2\relax
+ \setbox\scratchbox\hbox{\ignorespaces#1\unskip}%
+ \ifdim\wd\scratchbox>\afterassignwidth
+ \edef\afterassignwidth{\the\wd\scratchbox}%
+ \fi
+ \else
+ \supp_charalign_check#2#3\relax\relax
+ \fi}
+
+\unexpanded\def\supp_charalign_secondpass_one#1#2%
+ {\supp_charalign_pop
+ \let\\\empty % beware, no grouping
+ \setbox\scratchbox\hbox{#1}%
+ \d_supp_charalign_width\wd\scratchbox
+ \setbox\scratchbox\emptyhbox
+ % new 12,34 vs 10\\ where 10 aligns on 12 if #1 = ,
+ \ifcase\characteralignmentslot
+ \supp_charalign_check#2#1\relax\relax
+ \scratchdimen\wd\scratchbox
+ \setbox\scratchbox\hbox{\ignorespaces##1\unskip}%
+ \else
+ \def\\{#1}%
+ \normalexpanded{\supp_charalign_check#2#1\relax\relax}%
+ \scratchdimen\wd\scratchbox
+ \setbox\scratchbox\hbox{\def\\{\hphantom{#1}}\ignorespaces#2\unskip}%
+ \fi
+ \noindent
+ \ifdim\scratchdimen=\wd\scratchbox
+ \ifcase\characteralignmentmode
+ \box\scratchbox
+ \else
+ \hbox
+ {\dontcomplain
+ \hbox to \beforeassignwidth
+ {\ifcase\characteralignmentmode\or
+ \box\scratchbox\hss
+ \or
+ \hss\box\scratchbox\hskip\d_supp_charalign_width
+ \or
+ \hss\rlap{\box\scratchbox}%
+ \or
+ \hss\rlap{\hbox to \afterassignwidth{\hss\box\scratchbox}}%
+ \fi}%
+ \hskip\afterassignwidth}%
+ \fi
+ \else
+ \hbox
+ {\hbox to \beforeassignwidth
+ {\hss\box\scratchbox\hskip-\scratchdimen}%
+ \hskip\afterassignwidth}%
+ \fi}
+
+\unexpanded\def\supp_charalign_secondpass_two#1#2#3%
+ {\ifx#2\relax
+ \setbox\scratchbox\hbox{\ignorespaces#1\unskip}%
+ \else
+ \supp_charalign_check#2#3\relax\relax
+ \fi}
+
+\unexpanded\def\supp_charalign_firstpass#1%
+ {\unexpanded\def\checkalignment ##1{\supp_charalign_firstpass_one{#1}{##1}}%
+ \unexpanded\def\supp_charalign_check##1#1##2##3\relax{\supp_charalign_firstpass_two{##1}{##2}{##3}}}
+
+\unexpanded\def\supp_charalign_secondpass#1%
+ {\unexpanded\def\checkalignment ##1{\supp_charalign_secondpass_one{#1}{##1}}%
+ \unexpanded\def\supp_charalign_check##1#1##2##3\relax{\supp_charalign_secondpass_two{##1}{##2}{##3}}}
+
+\unexpanded\def\setfirstpasscharacteralign
+ {\supp_charalign_pop
+ \normalexpanded{\supp_charalign_firstpass{\alignmentcharacter}}}
+
+\unexpanded\def\setsecondpasscharacteralign
+ {\supp_charalign_pop
+ \normalexpanded{\supp_charalign_secondpass{\alignmentcharacter}}}
+
+\unexpanded\def\startcharacteralign#1\stopcharacteralign
+ {\bgroup
+ \setfirstpasscharacteralign #1%
+ \setsecondpasscharacteralign#1%
+ \egroup}
+
+\let\stopcharacteralign\relax
+
+\protect \endinput
diff --git a/tex/context/base/spac-chr.lua b/tex/context/base/spac-chr.lua
index db98b42a6..24364978a 100644
--- a/tex/context/base/spac-chr.lua
+++ b/tex/context/base/spac-chr.lua
@@ -14,22 +14,19 @@ local byte, lower = string.byte, string.lower
-- to be redone: characters will become tagged spaces instead as then we keep track of
-- spaceskip etc
-local next = next
-
trace_characters = false trackers.register("typesetters.characters", function(v) trace_characters = v end)
report_characters = logs.reporter("typesetting","characters")
local nodes, node = nodes, node
-local insert_node_after = nodes.insert_after
-local remove_node = nodes.remove
-local copy_node_list = nodes.copy_list
-local traverse_id = nodes.traverse_id
+local insert_node_after = node.insert_after
+local remove_node = nodes.remove -- ! nodes
+local copy_node_list = node.copy_list
+local nodepool = nodes.pool
local tasks = nodes.tasks
-local nodepool = nodes.pool
local new_penalty = nodepool.penalty
local new_glue = nodepool.glue
@@ -44,9 +41,7 @@ local chardata = characters.data
local typesetters = typesetters
-local unicodeblocks = characters.blocks
-
-local characters = typesetters.characters or { } -- can be predefined
+local characters = { }
typesetters.characters = characters
local fonthashes = fonts.hashes
@@ -54,8 +49,6 @@ local fontparameters = fonthashes.parameters
local fontcharacters = fonthashes.characters
local fontquads = fonthashes.quads
-local setmetatableindex = table.setmetatableindex
-
local a_character = attributes.private("characters")
local a_alignstate = attributes.private("alignstate")
@@ -81,6 +74,7 @@ local function inject_char_space(unicode,head,current,parent)
local font = current.font
local char = fontcharacters[font][parent]
local glue = new_glue(char and char.width or fontparameters[font].space)
+ -- glue.attr = copy_node_list(current.attr)
glue.attr = current.attr
current.attr = nil
glue[a_character] = unicode
@@ -92,78 +86,30 @@ local function inject_nobreak_space(unicode,head,current,space,spacestretch,spac
local attr = current.attr
local glue = new_glue(space,spacestretch,spaceshrink)
local penalty = new_penalty(10000)
+ -- glue.attr = copy_node_list(attr)
glue.attr = attr
current.attr = nil
+ -- penalty.attr = attr
glue[a_character] = unicode
head, current = insert_node_after(head,current,penalty)
head, current = insert_node_after(head,current,glue)
return head, current
end
-local function nbsp(head,current)
- local para = fontparameters[current.font]
- if current[a_alignstate] == 1 then -- flushright
- head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0)
- current.subtype = space_skip_code
- else
- head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink)
- end
- return head, current
-end
-
--- assumes nuts or nodes, depending on callers .. so no tonuts here
-
-function characters.replacenbsp(head,original)
- local head, current = nbsp(head,original)
- head = remove_node(head,original,true)
- return head, current
-end
-
-function characters.replacenbspaces(head)
- for current in traverse_id(glyph_code,head) do
- if current.char == 0x00A0 then
- local h = nbsp(head,current)
- if h then
- head = remove_node(h,current,true)
- end
- end
- end
- return head
-end
-
--- This initialization might move someplace else if we need more of it. The problem is that
--- this module depends on fonts so we have an order problem.
-
-local nbsphash = { } setmetatableindex(nbsphash,function(t,k)
- for i=unicodeblocks.devanagari.first,unicodeblocks.devanagari.last do nbsphash[i] = true end
- for i=unicodeblocks.kannada .first,unicodeblocks.kannada .last do nbsphash[i] = true end
- setmetatableindex(nbsphash,nil)
- return nbsphash[k]
-end)
-
local methods = {
-- The next one uses an attribute assigned to the character but still we
-- don't have the 'local' value.
[0x00A0] = function(head,current) -- nbsp
- local next = current.next
- if next and next.id == glyph_code then
- local char = next.char
- if char == 0x200C or char == 0x200D then -- nzwj zwj
- next = next.next
- if next and nbsphash[next.char] then
- return false
- end
- elseif nbsphash[char] then
- return false
- end
- end
- local prev = current.prev
- if prev and prev.id == glyph_code and nbsphash[prev.char] then
- return false -- kannada
+ local para = fontparameters[current.font]
+ if current[a_alignstate] == 1 then -- flushright
+ head, current = inject_nobreak_space(0x00A0,head,current,para.space,0,0)
+ current.subtype = space_skip_code
+ else
+ head, current = inject_nobreak_space(0x00A0,head,current,para.space,para.spacestretch,para.spaceshrink)
end
- return nbsp(head,current)
+ return head, current
end,
[0x2000] = function(head,current) -- enquad
@@ -241,10 +187,8 @@ function characters.handler(head)
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
+ head = method(head,current)
+ head = remove_node(head,current,true)
done = true
end
current = next
diff --git a/tex/context/base/spac-chr.mkiv b/tex/context/base/spac-chr.mkiv
index 54a25be34..0b6ebe0a9 100644
--- a/tex/context/base/spac-chr.mkiv
+++ b/tex/context/base/spac-chr.mkiv
@@ -68,16 +68,13 @@
\edef\breakablethinspace {\normalUchar"2009} % quad/8
\edef\hairspace {\normalUchar"200A} % quad/8
\edef\zerowidthspace {\normalUchar"200B} % 0
-\edef\zerowidthnonjoiner {\normalUchar"200C} % 0
-\edef\zerowidthjoiner {\normalUchar"200D} % 0
+\edef\zwnj {\normalUchar"200C} % 0
+\edef\zwj {\normalUchar"200D} % 0
\edef\narrownobreakspace {\normalUchar"202F} % quad/8
% % "205F % space/8 (math)
% \zerowidthnobreakspace {\normalUchar"FEFF}
\udef\zerowidthnobreakspace {\penalty\plustenthousand\kern\zeropoint}
-\let\zwnj\zerowidthnonjoiner
-\let\zwj \zerowidthjoiner
-
% Shortcuts:
% unexpanded as otherwise we need to intercept / cleanup a lot
diff --git a/tex/context/base/spac-hor.lua b/tex/context/base/spac-hor.lua
index c9d6e2b15..09920bd46 100644
--- a/tex/context/base/spac-hor.lua
+++ b/tex/context/base/spac-hor.lua
@@ -8,10 +8,6 @@ if not modules then modules = { } end modules ['spac-hor'] = {
local match = string.match
local utfbyte = utf.byte
-
-local context = context
-local commands = commands
-
local chardata = characters.data
local can_have_space = table.tohash {
diff --git a/tex/context/base/spac-hor.mkiv b/tex/context/base/spac-hor.mkiv
index 73e4771fe..2ce502fb5 100644
--- a/tex/context/base/spac-hor.mkiv
+++ b/tex/context/base/spac-hor.mkiv
@@ -486,17 +486,17 @@
\ifdefined\thinspace \else
- \unexpanded\def\thinspace {\kern .16667\emwidth}
- \unexpanded\def\negthinspace{\kern-.16667\emwidth}
- \unexpanded\def\enspace {\kern .5\emwidth}
+ \def\thinspace {\kern .16667\emwidth}
+ \def\negthinspace{\kern-.16667\emwidth}
+ \def\enspace {\kern .5\emwidth}
\fi
\ifdefined\quad \else
- \unexpanded\def\enskip{\hskip.5\emwidth}
- \unexpanded\def\quad {\hskip \emwidth}
- \unexpanded\def\qquad {\hskip 2\emwidth}
+ \def\enskip{\hskip.5\emwidth}
+ \def\quad {\hskip \emwidth}
+ \def\qquad {\hskip 2\emwidth}
\fi
@@ -613,51 +613,14 @@
{\begingroup
\dodoubleempty\spac_narrower_start_named}
-% \def\spac_narrower_start_named[#1][#2]%
-% {\edef\currentnarrower{#1}%
-% \ifsecondargument
-% \spac_narrower_start_apply{#2}%
-% \else
-% \spac_narrower_start_apply{\narrowerparameter\v!default}%
-% \fi}
-
-\def\spac_narrower_start_named
- {\ifsecondargument
- \expandafter\spac_narrower_start_named_two
+\def\spac_narrower_start_named[#1][#2]%
+ {\edef\currentnarrower{#1}%
+ \ifsecondargument
+ \spac_narrower_start_apply{#2}%
\else
- \expandafter\spac_narrower_start_named_one
+ \spac_narrower_start_apply{\narrowerparameter\v!default}%
\fi}
-\def\spac_narrower_start_named_one[#1]%
- {\doifassignmentelse{#1}\spac_narrower_start_named_one_yes\spac_narrower_start_named_one_nop[#1]}
-
-\def\spac_narrower_start_named_one_yes[#1][#2]% [settings] []
- {\setupcurrentnarrower[#1]%
- \spac_narrower_start_apply{\narrowerparameter\v!default}}
-
-\def\spac_narrower_start_named_one_nop[#1][#2]% [tag] []
- {\edef\currentnarrower{#1}%
- \spac_narrower_start_apply{\narrowerparameter\v!default}}
-
-\def\spac_narrower_start_named_two[#1]%
- {\doifassignmentelse{#1}\spac_narrower_start_named_settings_how\spac_narrower_start_named_tag_unknown[#1]}
-
-\def\spac_narrower_start_named_settings_how[#1][#2]% [settings] [how]
- {\setupcurrentnarrower[#1]%
- \spac_narrower_start_apply{#2}}
-
-\def\spac_narrower_start_named_tag_unknown[#1][#2]% [tag] [...]
- {\doifassignmentelse{#2}\spac_narrower_start_named_tag_settings\spac_narrower_start_named_tag_how[#1][#2]}
-
-\def\spac_narrower_start_named_tag_settings[#1][#2]% [tag] [settings]
- {\edef\currentnarrower{#1}%
- \setupcurrentnarrower[#2]%
- \spac_narrower_start_apply{\narrowerparameter\v!default}}
-
-\def\spac_narrower_start_named_tag_how[#1][#2]% [tag] [how]
- {\edef\currentnarrower{#1}%
- \spac_narrower_start_apply{#2}}
-
\let\stopnarrow\spac_narrower_stop
\newdimen\d_spac_effective_hsize \def\effectivehsize {\hsize}
diff --git a/tex/context/base/spac-ver.lua b/tex/context/base/spac-ver.lua
index 7bca7e8a1..7d030ab1a 100644
--- a/tex/context/base/spac-ver.lua
+++ b/tex/context/base/spac-ver.lua
@@ -23,7 +23,8 @@ if not modules then modules = { } end modules ['spac-ver'] = {
local next, type, tonumber = next, type, tonumber
local gmatch, concat = string.gmatch, table.concat
-local ceil, floor = math.ceil, math.floor
+local ceil, floor, max, min, round, abs = math.ceil, math.floor, math.max, math.min, math.round, math.abs
+local texlists, texdimen, texbox = tex.lists, tex.dimen, tex.box
local lpegmatch = lpeg.match
local unpack = unpack or table.unpack
local allocate = utilities.storage.allocate
@@ -32,14 +33,13 @@ local formatters = string.formatters
local P, C, R, S, Cc = lpeg.P, lpeg.C, lpeg.R, lpeg.S, lpeg.Cc
-local nodes, node, trackers, attributes, context, commands, tex = nodes, node, trackers, attributes, context, commands, tex
-
------ texlists = tex.lists
-local texgetdimen = tex.getdimen
-local texgetbox = tex.getbox
+local nodes, node, trackers, attributes, context = nodes, node, trackers, attributes, context
local variables = interfaces.variables
+local starttiming = statistics.starttiming
+local stoptiming = statistics.stoptiming
+
-- vertical space handler
local trace_vbox_vspacing = false trackers.register("vspacing.vbox", function(v) trace_vbox_vspacing = v end)
@@ -87,6 +87,7 @@ local new_gluespec = nodepool.gluespec
local nodecodes = nodes.nodecodes
local skipcodes = nodes.skipcodes
+local fillcodes = nodes.fillcodes
local penalty_code = nodecodes.penalty
local kern_code = nodecodes.kern
@@ -95,7 +96,7 @@ local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
local whatsit_code = nodecodes.whatsit
-local texnest = tex.nest
+local userskip_code = skipcodes.userskip
local vspacing = builders.vspacing or { }
builders.vspacing = vspacing
@@ -287,24 +288,20 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is
local snapht, snapdp
if method["local"] then
-- snapping is done immediately here
- snapht = texgetdimen("bodyfontstrutheight")
- snapdp = texgetdimen("bodyfontstrutdepth")
+ snapht, snapdp = texdimen.bodyfontstrutheight, texdimen.bodyfontstrutdepth
if t then
t[#t+1] = formatters["local: snapht %p snapdp %p"](snapht,snapdp)
end
elseif method["global"] then
- snapht = texgetdimen("globalbodyfontstrutheight")
- snapdp = texgetdimen("globalbodyfontstrutdepth")
+ snapht, snapdp = texdimen.globalbodyfontstrutheight, texdimen.globalbodyfontstrutdepth
if t then
t[#t+1] = formatters["global: snapht %p snapdp %p"](snapht,snapdp)
end
else
-- maybe autolocal
-- snapping might happen later in the otr
- snapht = texgetdimen("globalbodyfontstrutheight")
- snapdp = texgetdimen("globalbodyfontstrutdepth")
- local lsnapht = texgetdimen("bodyfontstrutheight")
- local lsnapdp = texgetdimen("bodyfontstrutdepth")
+ snapht, snapdp = texdimen.globalbodyfontstrutheight, texdimen.globalbodyfontstrutdepth
+ local lsnapht, lsnapdp = texdimen.bodyfontstrutheight, texdimen.bodyfontstrutdepth
if snapht ~= lsnapht and snapdp ~= lsnapdp then
snapht, snapdp = lsnapht, lsnapdp
end
@@ -345,16 +342,13 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is
id = thebox and thebox.id
end
if thebox and id == vlist_code then
- local list = thebox.list
- local lh, ld
+ local list, lh, ld = thebox.list
for n in traverse_nodes_id(hlist_code,list) do
- lh = n.height
- ld = n.depth
+ lh, ld = n.height, n.depth
break
end
if lh then
- local ht = thebox.height
- local dp = thebox.depth
+ local ht, dp = thebox.height, thebox.depth
if t then
t[#t+1] = formatters["first line: height %p depth %p"](lh,ld)
t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
@@ -385,12 +379,10 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is
if thebox and id == vlist_code then
local list, lh, ld = thebox.list
for n in traverse_nodes_id(hlist_code,list) do
- lh = n.height
- ld = n.depth
+ lh, ld = n.height, n.depth
end
if lh then
- local ht = thebox.height
- local dp = thebox.depth
+ local ht, dp = thebox.height, thebox.depth
if t then
t[#t+1] = formatters["last line: height %p depth %p" ](lh,ld)
t[#t+1] = formatters["dimensions: height %p depth %p"](ht,dp)
@@ -487,7 +479,7 @@ local function snap_hlist(where,current,method,height,depth) -- method.strut is
local lines = (ch+cd)/snaphtdp
if t then
local original = (h+d)/snaphtdp
- local whatever = (ch+cd)/(texgetdimen("globalbodyfontstrutheight") + texgetdimen("globalbodyfontstrutdepth"))
+ local whatever = (ch+cd)/(texdimen.globalbodyfontstrutheight + texdimen.globalbodyfontstrutdepth)
t[#t+1] = formatters["final lines: %s -> %s (%s)"](original,lines,whatever)
t[#t+1] = formatters["final height: %p -> %p"](h,ch)
t[#t+1] = formatters["final depth: %p -> %p"](d,cd)
@@ -503,8 +495,7 @@ local function snap_topskip(current,method)
local w = spec.width
local wd = w
if spec.writable then
- spec.width = 0
- wd = 0
+ spec.width, wd = 0, 0
end
return w, wd
end
@@ -749,11 +740,21 @@ local topskip_code = skipcodes.topskip
local splittopskip_code = skipcodes.splittopskip
local free_glue_node = free_node
+local discard, largest, force, penalty, add, disable, nowhite, goback, together = 0, 1, 2, 3, 4, 5, 6, 7, 8
+
+-- local function free_glue_node(n)
+-- -- free_node(n.spec)
+-- print("before",n)
+-- logs.flush()
+-- free_node(n)
+-- print("after")
+-- logs.flush()
+-- end
function vspacing.snapbox(n,how)
local sv = snapmethods[how]
if sv then
- local box = texgetbox(n)
+ local box = texbox[n]
local list = box.list
if list then
local s = list[a_snapmethod]
@@ -762,8 +763,7 @@ function vspacing.snapbox(n,how)
-- report_snapper("box list not snapped, already done")
end
else
- local ht = box.height
- local dp = box.depth
+ local ht, dp = box.height, box.depth
if false then -- todo: already_done
-- assume that the box is already snapped
if trace_vsnapping then
@@ -772,8 +772,7 @@ function vspacing.snapbox(n,how)
end
else
local h, d, ch, cd, lines = snap_hlist("box",box,sv,ht,dp)
- box.height= ch
- box.depth = cd
+ box.height, box.depth = ch, cd
if trace_vsnapping then
report_snapper("box list snapped from (%p,%p) to (%p,%p) using method %a (%s) for %a (%s lines): %s",
h,d,ch,cd,sv.name,sv.specification,"direct",lines,listtoutf(list))
@@ -786,17 +785,8 @@ function vspacing.snapbox(n,how)
end
end
--- I need to figure out how to deal with the prevdepth that crosses pages. In fact,
--- prevdepth is often quite interfering (even over a next paragraph) so I need to
--- figure out a trick.
-
local function forced_skip(head,current,width,where,trace)
- if head == current and head.subtype == baselineskip_code then
- width = width - head.spec.width
- end
- if width == 0 then
- -- do nothing
- elseif where == "after" then
+ if where == "after" then
head, current = insert_node_after(head,current,new_rule(0,0,0))
head, current = insert_node_after(head,current,new_kern(width))
head, current = insert_node_after(head,current,new_rule(0,0,0))
@@ -815,8 +805,6 @@ end
-- penalty only works well when before skip
-local discard, largest, force, penalty, add, disable, nowhite, goback, together = 0, 1, 2, 3, 4, 5, 6, 7, 8 -- move into function when upvalue 60 issue
-
local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also pass tail
if trace then
reset_tracing(head)
@@ -835,12 +823,11 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
head = insert_node_before(head,current,p)
end
if glue_data then
- local spec = glue_data.spec
if force_glue then
if trace then trace_done("flushed due to " .. why,glue_data) end
- head = forced_skip(head,current,spec.width,"before",trace)
+ head = forced_skip(head,current,glue_data.spec.width,"before",trace)
free_glue_node(glue_data)
- elseif spec.writable then
+ elseif glue_data.spec.writable then
if trace then trace_done("flushed due to " .. why,glue_data) end
head = insert_node_before(head,current,glue_data)
else
@@ -854,9 +841,8 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
end
if trace_vsnapping then
report_snapper("global ht/dp = %p/%p, local ht/dp = %p/%p",
- texgetdimen("globalbodyfontstrutheight"), texgetdimen("globalbodyfontstrutdepth"),
- texgetdimen("bodyfontstrutheight"), texgetdimen("bodyfontstrutdepth")
- )
+ texdimen.globalbodyfontstrutheight, texdimen.globalbodyfontstrutdepth,
+ texdimen.bodyfontstrutheight, texdimen.bodyfontstrutdepth)
end
if trace then trace_info("start analyzing",where,what) end
while current do
@@ -879,8 +865,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if sv then
-- check if already snapped
if list and already_done(id,list,a_snapmethod) then
- local ht = current.height
- local dp = current.depth
+ local ht, dp = current.height, current.depth
-- assume that the box is already snapped
if trace_vsnapping then
report_snapper("mvl list already snapped at (%p,%p): %s",ht,dp,listtoutf(list))
@@ -951,9 +936,9 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
previous.spec = new_gluespec(pw + cw, pp + cp, pm + cm) -- else topskip can disappear
if trace then trace_natural("removed",current) end
head, current = remove_node(head, current, true)
- -- current = previous
+ -- current = previous
if trace then trace_natural("collapsed",previous) end
- -- current = current.next
+ -- current = current.next
else
if trace then trace_natural("filler",current) end
current = current.next
@@ -1090,8 +1075,7 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
if trace then trace_natural("ignored parskip",current) end
head, current = remove_node(head, current, true)
elseif glue_data then
- local ps = current.spec
- local gs = glue_data.spec
+ local ps, gs = current.spec, glue_data.spec
if ps.writable and gs.writable and ps.width > gs.width then
glue_data.spec = copy_node(ps)
if trace then trace_natural("taking parskip",current) end
@@ -1147,14 +1131,11 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
current = current.next
--
else -- other glue
- if snap and trace_vsnapping then
- local spec = current.spec
- if spec.writable and spec.width ~= 0 then
- report_snapper("glue %p of type %a kept",current.spec.width,skipcodes[subtype])
- -- spec.width = 0
- end
+ if snap and trace_vsnapping and current.spec.writable and current.spec.width ~= 0 then
+ report_snapper("glue %p of type %a kept",current.spec.width,skipcodes[subtype])
+ --~ current.spec.width = 0
end
- if trace then trace_skip(formatter["glue of type %a"](subtype),sc,so,sp,current) end
+ if trace then trace_skip(formatted["glue of type %a"](subtype),sc,so,sp,current) end
flush("some glue")
current = current.next
end
@@ -1186,7 +1167,6 @@ local function collapser(head,where,what,trace,snap,a_snapmethod) -- maybe also
else
head, tail = insert_node_after(head,tail,glue_data)
end
-texnest[texnest.ptr].prevdepth = 0 -- appending to the list bypasses tex's prevdepth handler
end
if trace then
if glue_data or penalty_data then
@@ -1247,11 +1227,11 @@ function vspacing.pagehandler(newhead,where)
if stackhack then
stackhack = false
if trace_collect_vspacing then report("processing %s nodes: %s",newhead) end
- -- texlists.contrib_head = collapser(newhead,"page",where,trace_page_vspacing,true,a_snapmethod)
+--~ 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("flushing %s nodes: %s",newhead) end
- -- texlists.contrib_head = newhead
+--~ texlists.contrib_head = newhead
end
else
if stackhead then
@@ -1278,30 +1258,97 @@ local ignore = table.tohash {
function vspacing.vboxhandler(head,where)
if head and not ignore[where] and head.next then
+ -- starttiming(vspacing)
head = collapser(head,"vbox",where,trace_vbox_vspacing,true,a_snapvbox) -- todo: local snapper
+ -- stoptiming(vspacing)
end
return head
end
function vspacing.collapsevbox(n) -- for boxes but using global a_snapmethod
- local box = texgetbox(n)
- if box then
- local list = box.list
- if list then
- box.list = vpack_node(collapser(list,"snapper","vbox",trace_vbox_vspacing,true,a_snapmethod))
+ local list = texbox[n].list
+ if list then
+ -- starttiming(vspacing)
+ texbox[n].list = vpack_node(collapser(list,"snapper","vbox",trace_vbox_vspacing,true,a_snapmethod))
+ -- stoptiming(vspacing)
+ end
+end
+
+-- We will split this module so a few locals are repeated. Also this will be
+-- rewritten.
+
+nodes.builders = nodes.builder or { }
+local builders = nodes.builders
+
+local actions = nodes.tasks.actions("vboxbuilders")
+
+function builders.vpack_filter(head,groupcode,size,packtype,maxdepth,direction)
+ local done = false
+ if head then
+ starttiming(builders)
+ if trace_vpacking then
+ local before = nodes.count(head)
+ head, done = actions(head,groupcode,size,packtype,maxdepth,direction)
+ local after = nodes.count(head)
+ if done then
+ nodes.processors.tracer("vpack","changed",head,groupcode,before,after,true)
+ else
+ nodes.processors.tracer("vpack","unchanged",head,groupcode,before,after,true)
+ end
+ else
+ head, done = actions(head,groupcode)
end
+ stoptiming(builders)
end
+ return head, done
end
--- This one is needed to prevent bleeding of prevdepth to the next page
--- which doesn't work well with forced skips.
+-- This one is special in the sense that it has no head and we operate on the mlv. Also,
+-- we need to do the vspacing last as it removes items from the mvl.
+
+local actions = nodes.tasks.actions("mvlbuilders")
-local outer = texnest[0]
+local function report(groupcode,head)
+ report_page_builder("trigger: %s",groupcode)
+ report_page_builder(" vsize : %p",tex.vsize)
+ report_page_builder(" pagegoal : %p",tex.pagegoal)
+ report_page_builder(" pagetotal: %p",tex.pagetotal)
+ report_page_builder(" list : %s",head and nodeidstostring(head) or "")
+end
-function vspacing.resetprevdepth()
- outer.prevdepth = 0
+function builders.buildpage_filter(groupcode)
+ local head, done = texlists.contrib_head, false
+ -- if head and head.next and head.next.id == hlist_code and head.next.width == 1 then
+ -- report_page_builder("trigger otr calculations")
+ -- free_node_list(head)
+ -- head = nil
+ -- end
+ if head then
+ starttiming(builders)
+ if trace_page_builder then
+ report(groupcode,head)
+ end
+ head, done = actions(head,groupcode)
+ stoptiming(builders)
+ -- -- doesn't work here (not passed on?)
+ -- tex.pagegoal = tex.vsize - tex.dimen.d_page_floats_inserted_top - tex.dimen.d_page_floats_inserted_bottom
+ texlists.contrib_head = head
+ return done and head or true
+ else
+ if trace_page_builder then
+ report(groupcode)
+ end
+ return nil, false
+ end
end
+callbacks.register('vpack_filter', builders.vpack_filter, "vertical spacing etc")
+callbacks.register('buildpage_filter', builders.buildpage_filter, "vertical spacing etc (mvl)")
+
+statistics.register("v-node processing time", function()
+ return statistics.elapsedseconds(builders)
+end)
+
-- interface
commands.vspacing = vspacing.analyze
@@ -1309,4 +1356,3 @@ commands.vspacingsetamount = vspacing.setskip
commands.vspacingdefine = vspacing.setmap
commands.vspacingcollapse = vspacing.collapsevbox
commands.vspacingsnap = vspacing.snapbox
-commands.resetprevdepth = vspacing.resetprevdepth
diff --git a/tex/context/base/spac-ver.mkiv b/tex/context/base/spac-ver.mkiv
index f535a59f6..ee78d8964 100644
--- a/tex/context/base/spac-ver.mkiv
+++ b/tex/context/base/spac-ver.mkiv
@@ -715,10 +715,6 @@
\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
@@ -917,7 +913,7 @@
\s!depth \strutdp}}
\def\spac_struts_set_vide
- {\setbox\strutbox\hbox % at some time this extra wrapping was needed
+ {\setbox\strutbox\hbox
{\spac_struts_vide_hbox to \zeropoint
{% \hss % new, will be option
\vrule
@@ -943,8 +939,8 @@
\unexpanded\def\strut % still callbacks for \hbox{\strut}
{\relax
- \dontleavehmode
- \copy\strutbox}
+ \dontleavehmode
+ \copy\strutbox}
\let\normalstrut\strut
@@ -988,7 +984,7 @@
\setcharstrut\m_strut
\fi}
-\unexpanded\def\showstruts % adapts .. is wrong
+\unexpanded\def\showstruts
{\setteststrut
\settestcrlf}
@@ -2077,42 +2073,4 @@
%
% \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
-
-% not ok, so we need to figure out another way to fix this messy prevdepth-across-page issue
-% as encountered in forced blank skips (see lua code)
-%
-% \appendtoks
-% \ifvmode\ctxcommand{resetprevdepth()}\fi
-% \to \everyafteroutput
-%
-% this should only happen when there is nothing left over (how to detemine that) .. testcase:
-%
-% \dorecurse{41}{line\par}
-% \starttyping
-% line 1
-% line 2
-% line 3
-% \stoptyping
-
\protect \endinput
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index deaf92e71..097fe5a2d 100644
Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index e3dfc12ac..f727ca843 100644
Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ
diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua
index caa7dc16c..443eee60e 100644
--- a/tex/context/base/status-mkiv.lua
+++ b/tex/context/base/status-mkiv.lua
@@ -1259,12 +1259,6 @@ return {
loading = "always",
status = "okay",
},
- {
- category = "mkiv",
- filename = "typo-tal",
- loading = "always",
- status = "okay",
- },
{
category = "mkiv",
comment = "somewhat weird",
@@ -1496,6 +1490,12 @@ return {
loading = "always",
status = "okay",
},
+ {
+ category = "mkiv",
+ filename = "spac-cha",
+ loading = "always",
+ status = "okay",
+ },
{
category = "mkiv",
comment = "work in progress",
@@ -1586,13 +1586,8 @@ return {
},
{
category = "mkiv",
- filename = "typo-drp",
- loading = "always",
- status = "okay",
- },
- {
- category = "mkiv",
- filename = "typo-fln",
+ comment = "might get extended",
+ filename = "typo-par",
loading = "always",
status = "okay",
},
@@ -1684,12 +1679,6 @@ return {
loading = "experimental",
status = "okay",
},
- {
- category = "mkiv",
- filename = "meta-fnt",
- loading = "always",
- status = "okay",
- },
{
category = "mkiv",
filename = "meta-tex",
@@ -1828,12 +1817,6 @@ return {
loading = "always",
status = "okay",
},
- {
- category = "mkvi",
- filename = "math-acc",
- loading = "always",
- status = "okay",
- },
{
category = "mkiv",
comment = "at least for the moment",
@@ -1866,12 +1849,6 @@ return {
loading = "always",
status = "okay",
},
- {
- category = "mkiv",
- filename = "math-rad",
- loading = "always",
- status = "okay",
- },
{
category = "mkiv",
comment = "code might move to here",
@@ -3737,12 +3714,7 @@ return {
{
category = "lua",
filename = "m-database",
- status = "okay",
- },
- {
- category = "lua",
- filename = "m-nodechart",
- status = "okay",
+ status = "todo",
},
{
category = "lua",
@@ -3864,12 +3836,6 @@ return {
loading = "meta-lua",
status = "okay",
},
- {
- category = "lua",
- filename = "meta-fnt",
- loading = "meta-fnt",
- status = "okay",
- },
{
category = "lua",
comment = "could be done nicer nowadays but who needs it",
@@ -4776,40 +4742,13 @@ return {
{
category = "lua",
filename = "typo-dir",
- loading = "typo-dir",
- status = "okay",
- },
- {
- category = "lua",
- comment = "work in progress",
- filename = "typo-dha",
- loading = "typo-dir",
status = "todo",
},
- {
- category = "lua",
- filename = "typo-dua",
- loading = "typo-dir",
- status = "okay",
- },
- {
- category = "lua",
- comment = "work in progress",
- filename = "typo-dub",
- loading = "typo-dir",
- status = "okay",
- },
{
category = "lua",
filename = "typo-ini",
status = "todo",
},
- {
- category = "mkiv",
- filename = "typo-tal",
- loading = "typo-tal",
- status = "okay",
- },
{
category = "lua",
filename = "typo-itc",
@@ -4832,13 +4771,8 @@ return {
},
{
category = "lua",
- filename = "typo-drp",
- status = "okay",
- },
- {
- category = "lua",
- filename = "typo-fln",
- status = "okay",
+ filename = "typo-par",
+ status = "todo",
},
{
category = "lua",
@@ -5156,12 +5090,7 @@ return {
{
category = "mkiv",
filename = "m-database",
- status = "okay",
- },
- {
- category = "mkiv",
- filename = "m-nodechart",
- status = "okay",
+ status = "todo",
},
{
category = "tex",
diff --git a/tex/context/base/strc-blk.lua b/tex/context/base/strc-blk.lua
index 935b6c061..791f8f99b 100644
--- a/tex/context/base/strc-blk.lua
+++ b/tex/context/base/strc-blk.lua
@@ -13,10 +13,7 @@ local find, format, validstring = string.find, string.format, string.valid
local settings_to_set, settings_to_array = utilities.parsers.settings_to_set, utilities.parsers.settings_to_array
local allocate = utilities.storage.allocate
-local context = context
-local commands = commands
-
-local structures = structures
+local structures, context = structures, context
structures.blocks = structures.blocks or { }
diff --git a/tex/context/base/strc-con.mkvi b/tex/context/base/strc-con.mkvi
index 75519b8ce..11cd31983 100644
--- a/tex/context/base/strc-con.mkvi
+++ b/tex/context/base/strc-con.mkvi
@@ -246,24 +246,6 @@
\newconditional\c_strc_constructions_distance_none
-\def\strc_constructions_set_width_and_distance
- {\assignwidth
- \p_strc_constructions_width
- \constructionsheadwidth
- {\unhcopy\constructionheadbox}
- \constructionsheaddistance}
-
-\def\strc_constructions_preroll_head#content%
- {\setbox\constructionheadbox\hbox
- {\forgetall
- \dontcomplain
- \settrialtypesetting
- \csname\??constructionmainhandler\currentconstructionhandler\endcsname#content}}
-
-\def\strc_constructions_ignore_head
- {\constructionsheaddistance\zeropoint
- \constructionsheadwidth \zeropoint}
-
\unexpanded\setvalue{\??constructionstarthandler\v!construction}% this will be redone (reorganized) .. too much boxing
{\dostarttagged\t!construction\currentconstruction
\dotagsetconstruction
@@ -301,34 +283,21 @@
\fi
% inefficient and not always needed, for instance not with margins so we will make checkers
% per alternative some day (especially in labels this is unwanted overhead)
- %
- % maybe we should have an option as i cannot oversee the consequences now
- %
- % \edef\p_strc_constructions_sample{\constructionparameter\c!sample}%
- % \ifx\p_strc_constructions_sample\empty
- % \strc_constructions_preroll_head\currentconstructiontext
- % \else
- % \strc_constructions_preroll_head\currentconstructiontextsample
- % \fi
- % \strc_constructions_set_width_and_distance
- %
- \strc_constructions_preroll_head\currentconstructiontext
- \ifzeropt\wd\constructionheadbox
- \strc_constructions_ignore_head
- \else
- \edef\p_strc_constructions_sample{\constructionparameter\c!sample}%
- \ifx\p_strc_constructions_sample\empty
- \strc_constructions_set_width_and_distance
- \else
- \strc_constructions_preroll_head\currentconstructionsample
- \ifzeropt\wd\constructionheadbox
- \strc_constructions_ignore_head
- \else
- \strc_constructions_set_width_and_distance
- \fi
- \fi
- \fi
- %
+ \setbox\constructionheadbox\hbox
+ {\forgetall
+ \dontcomplain
+ \settrialtypesetting
+ \edef\p_strc_constructions_sample{\constructionparameter\c!sample}%
+ \ifx\p_strc_constructions_sample\empty
+ \csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructiontext
+ \else
+ \csname\??constructionmainhandler\currentconstructionhandler\endcsname\currentconstructionsample
+ \fi}%
+ \assignwidth
+ \p_strc_constructions_width
+ \constructionsheadwidth
+ {\unhcopy\constructionheadbox}
+ \constructionsheaddistance
\dostarttagged\t!constructiontag\empty % todo
\setbox\constructionheadbox\hbox
{\forgetall
@@ -740,8 +709,7 @@
\startsetups[\??constructionrenderings:\v!serried:\v!fit]
\let\\=\crlf
\noindent
- \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox % why copy? leftover?
- \penalty\plustenthousand % new
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
\hskip\constructionsheaddistance\relax
\useconstructionstyleandcolor\c!style\c!color
\ignorespaces
@@ -750,9 +718,8 @@
\startsetups[\??constructionrenderings:\v!serried:\v!broad]
\let\\=\crlf
\noindent
- \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox % why copy? leftover?
+ \ifhbox\constructionheadbox\unhcopy\else\copy\fi\constructionheadbox
\ifconditional\c_strc_constructions_distance_none \else
- \penalty\plustenthousand % new
\hskip\constructionsheaddistance \!!plus .5\constructionsheaddistance \!!minus .25\constructionsheaddistance\relax
\fi
\useconstructionstyleandcolor\c!style\c!color
diff --git a/tex/context/base/strc-doc.lua b/tex/context/base/strc-doc.lua
index 5be5727f5..50a9e67a0 100644
--- a/tex/context/base/strc-doc.lua
+++ b/tex/context/base/strc-doc.lua
@@ -41,10 +41,9 @@ local trace_detail = false trackers.register("structures.detail", fu
local report_structure = logs.reporter("structure","sectioning")
+local structures = structures
local context = context
-local commands = commands
-local structures = structures
local helpers = structures.helpers
local documents = structures.documents
local sections = structures.sections
@@ -737,13 +736,13 @@ function sections.typesetnumber(entry,kind,...) -- kind='section','number','pref
applyprocessor(connector)
end
else
- if groupsuffix and kind ~= "prefix" then
- if result then
- result[#result+1] = strippedprocessor(groupsuffix)
- else
- applyprocessor(groupsuffix)
- end
- end
+if groupsuffix and kind ~= "prefix" then
+ if result then
+ result[#result+1] = strippedprocessor(groupsuffix)
+ else
+ applyprocessor(groupsuffix)
+ end
+end
if stopper then
if result then
result[#result+1] = strippedprocessor(stopper)
@@ -769,104 +768,94 @@ end
function sections.findnumber(depth,what) -- needs checking (looks wrong and slow too)
local data = data.status[depth or data.depth]
- if not data then
- return
- end
- local references = data.references
- if not references then
- return
- end
- local index = references.section
- local collected = sections.collected
- local sectiondata = collected[index]
- if sectiondata and sectiondata.hidenumber ~= true then -- can be nil
- local quit = what == v_previous or what == v_next
- if what == v_first or what == v_previous then
- for i=index,1,-1 do
- local s = collected[i]
- if s then
- local n = s.numbers
- if #n == depth and n[depth] and n[depth] ~= 0 then
- sectiondata = s
- if quit then
+ if data then
+ local index = data.references.section
+ local collected = sections.collected
+ local sectiondata = collected[index]
+ if sectiondata and sectiondata.hidenumber ~= true then -- can be nil
+ local quit = what == v_previous or what == v_next
+ if what == v_first or what == v_previous then
+ for i=index,1,-1 do
+ local s = collected[i]
+ if s then
+ local n = s.numbers
+ if #n == depth and n[depth] and n[depth] ~= 0 then
+ sectiondata = s
+ if quit then
+ break
+ end
+ elseif #n < depth then
break
end
- elseif #n < depth then
- break
end
end
- end
- elseif what == v_last or what == v_next then
- for i=index,#collected do
- local s = collected[i]
- if s then
- local n = s.numbers
- if #n == depth and n[depth] and n[depth] ~= 0 then
- sectiondata = s
- if quit then
+ elseif what == v_last or what == v_next then
+ for i=index,#collected do
+ local s = collected[i]
+ if s then
+ local n = s.numbers
+ if #n == depth and n[depth] and n[depth] ~= 0 then
+ sectiondata = s
+ if quit then
+ break
+ end
+ elseif #n < depth then
break
end
- elseif #n < depth then
- break
end
end
end
+ return sectiondata
end
- return sectiondata
end
end
function sections.finddata(depth,what)
local data = data.status[depth or data.depth]
- if not data then
- return
- end
- local references = data.references
- if not references then
- return
- end
- local index = references.listindex
- if not index then
- return
- end
- local collected = structures.lists.collected
- local quit = what == v_previous or what == v_next
- if what == v_first or what == v_previous then
- for i=index-1,1,-1 do
- local s = collected[i]
- if not s then
- break
- elseif s.metadata.kind == "section" then -- maybe check on name
- local n = s.numberdata.numbers
- if #n == depth and n[depth] and n[depth] ~= 0 then
- data = s
- if quit then
+ if data then
+ -- if sectiondata and sectiondata.hidenumber ~= true then -- can be nil
+ local index = data.references.listindex
+ if index then
+ local collected = structures.lists.collected
+ local quit = what == v_previous or what == v_next
+ if what == v_first or what == v_previous then
+ for i=index-1,1,-1 do
+ local s = collected[i]
+ if not s then
break
+ elseif s.metadata.kind == "section" then -- maybe check on name
+ local n = s.numberdata.numbers
+ if #n == depth and n[depth] and n[depth] ~= 0 then
+ data = s
+ if quit then
+ break
+ end
+ elseif #n < depth then
+ break
+ end
end
- elseif #n < depth then
- break
end
- end
- end
- elseif what == v_last or what == v_next then
- for i=index+1,#collected do
- local s = collected[i]
- if not s then
- break
- elseif s.metadata.kind == "section" then -- maybe check on name
- local n = s.numberdata.numbers
- if #n == depth and n[depth] and n[depth] ~= 0 then
- data = s
- if quit then
+ elseif what == v_last or what == v_next then
+ for i=index+1,#collected do
+ local s = collected[i]
+ if not s then
break
+ elseif s.metadata.kind == "section" then -- maybe check on name
+ local n = s.numberdata.numbers
+ if #n == depth and n[depth] and n[depth] ~= 0 then
+ data = s
+ if quit then
+ break
+ end
+ elseif #n < depth then
+ break
+ end
end
- elseif #n < depth then
- break
end
end
end
+ return data
end
- return data
end
function sections.internalreference(sectionname,what) -- to be used in pagebuilder (no marks used)
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 065513db8..8122b953e 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -983,8 +983,6 @@
{\let\extrafloatlocation#rightpagelocation}%
{\let\extrafloatlocation#leftpagelocation}}
-\let\extrafloatlocation\empty
-
\installcorenamespace{extrafloataction}
\setvalue{\??extrafloataction \v!inner}#1{\strc_floats_set_extra_action\v!left \v!right}
@@ -1009,7 +1007,6 @@
\processcommacommand[\floatlocation]\strc_floats_check_extra_actions_step
\ifx\extrafloatlocation\empty \else
\edef\floatlocation{\extrafloatlocation,\floatlocation}%
- \setfloatmethodvariables\floatlocation
\fi}}
\def\strc_floats_check_extra_actions_step#step%
diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua
index 09ed79288..fd7c10f79 100644
--- a/tex/context/base/strc-ini.lua
+++ b/tex/context/base/strc-ini.lua
@@ -20,13 +20,12 @@ but it does not make sense to store all processdata.
]]--
+local formatters = string.formatters
local lpegmatch = lpeg.match
+local count = tex.count
local type, next, tonumber, select = type, next, tonumber, select
-
-local formatters = string.formatters
-local settings_to_array = utilities.parsers.settings_to_array
-local settings_to_hash = utilities.parsers.settings_to_hash
-local allocate = utilities.storage.allocate
+local settings_to_array, settings_to_hash = utilities.parsers.settings_to_array, utilities.parsers.settings_to_hash
+local allocate = utilities.storage.allocate
local catcodenumbers = catcodes.numbers -- better use the context(...) way to switch
@@ -35,8 +34,7 @@ local xmlcatcodes = catcodenumbers.xmlcatcodes
local notcatcodes = catcodenumbers.notcatcodes
local txtcatcodes = catcodenumbers.txtcatcodes
-local context = context
-local commands = commands
+local context, commands = context, commands
local pushcatcodes = context.pushcatcodes
local popcatcodes = context.popcatcodes
diff --git a/tex/context/base/strc-itm.lua b/tex/context/base/strc-itm.lua
index 4945c282f..8a745f356 100644
--- a/tex/context/base/strc-itm.lua
+++ b/tex/context/base/strc-itm.lua
@@ -10,19 +10,19 @@ local structures = structures
local itemgroups = structures.itemgroups
local jobpasses = job.passes
-local setvariable = jobpasses.save
-local getvariable = jobpasses.getfield
+local setfield = jobpasses.save
+local getfield = jobpasses.getfield
function itemgroups.register(name,nofitems,maxwidth)
- setvariable("itemgroup", { nofitems, maxwidth })
+ setfield("itemgroup", { nofitems, maxwidth })
end
function itemgroups.nofitems(name,index)
- return getvariable("itemgroup", index, 1, 0)
+ return getfield("itemgroup", index, 1, 0)
end
function itemgroups.maxwidth(name,index)
- return getvariable("itemgroup", index, 2, 0)
+ return getfield("itemgroup", index, 2, 0)
end
-- interface (might become counter/dimension)
@@ -30,9 +30,9 @@ end
commands.registeritemgroup = itemgroups.register
function commands.nofitems(name,index)
- context(getvariable("itemgroup", index, 1, 0))
+ context(getfield("itemgroup", index, 1, 0))
end
function commands.maxitemwidth(name,index)
- context(getvariable("itemgroup", index, 2, 0))
+ context(getfield("itemgroup", index, 2, 0))
end
diff --git a/tex/context/base/strc-itm.mkvi b/tex/context/base/strc-itm.mkvi
index 8259fa38d..85ec4bc45 100644
--- a/tex/context/base/strc-itm.mkvi
+++ b/tex/context/base/strc-itm.mkvi
@@ -408,6 +408,7 @@
\settrue\c_strc_itemgroups_inline
\settrue\c_strc_itemgroups_joined
\strc_itemgroups_process_set_option_pack}
+\setvalue{\??itemgroupkeyword\v!columns }{\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}
@@ -1204,8 +1205,7 @@
\def\strc_itemgroups_handle_lapped_item_positive
{\llap
- {\dontcomplain
- \hbox to \d_strc_itemgroups_list_width
+ {\hbox to \d_strc_itemgroups_list_width
{\ifconditional\c_strc_itemgroups_sub
\llap{+\enspace}%
\fi
@@ -1246,7 +1246,7 @@
\strc_itemgroups_start_head}
\def\strc_itemgroups_make_symbol_box
- {\setbox\b_strc_itemgroups\autodirhbox
+ {\setbox\b_strc_itemgroups\hbox
{\ifconditional\c_strc_itemgroups_head
\ifconditional\c_strc_itemgroups_symbol
\strc_itemgroups_insert_extra_reference
@@ -1444,19 +1444,6 @@
\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
diff --git a/tex/context/base/strc-lev.lua b/tex/context/base/strc-lev.lua
index 947889e1e..50a63c938 100644
--- a/tex/context/base/strc-lev.lua
+++ b/tex/context/base/strc-lev.lua
@@ -8,9 +8,6 @@ if not modules then modules = { } end modules ['strc-lev'] = {
local insert, remove = table.insert, table.remove
-local context = context
-local commands = commands
-
local sections = structures.sections
local default = interfaces.variables.default
diff --git a/tex/context/base/strc-lnt.mkvi b/tex/context/base/strc-lnt.mkvi
index f713ee20b..4a2cd1cc0 100644
--- a/tex/context/base/strc-lnt.mkvi
+++ b/tex/context/base/strc-lnt.mkvi
@@ -11,8 +11,6 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% todo: mkvi #
-
\writestatus{loading}{ConTeXt Structure Macros / Line Notes}
%D This module loads on top of the footnote and line numbering macros.
@@ -81,8 +79,6 @@
\letvalue\??linenotespreviousfrom\empty
\letvalue\??linenotespreviousto \empty
-% maybe do this in lua
-
\def\page_lines_in_from{\in[lr:b:\currentlinenotereference]}
\def\page_lines_in_to {\in[lr:e:\currentlinenotereference]}
@@ -117,11 +113,14 @@
\notationparameter\c!compressseparator
\else
\page_lines_in_from
- \ifx\m_page_lines_current_from\m_page_lines_current_to\else\endash\page_lines_in_to\fi
\fi
\else
\page_lines_in_from
- \ifx\m_page_lines_current_from\m_page_lines_current_to\else\endash\page_lines_in_to\fi
+ \ifx\m_page_lines_current_from\m_page_lines_current_to
+ \else
+ \endash
+ \page_lines_in_to
+ \fi
\fi
\else
\page_lines_in_from
diff --git a/tex/context/base/strc-lst.lua b/tex/context/base/strc-lst.lua
index f6a355707..305b6a6fa 100644
--- a/tex/context/base/strc-lst.lua
+++ b/tex/context/base/strc-lst.lua
@@ -17,6 +17,7 @@ if not modules then modules = { } end modules ['strc-lst'] = {
local format, gmatch, gsub = string.format, string.gmatch, string.gsub
local tonumber = tonumber
+local texcount = tex.count
local concat, insert, remove = table.concat, table.insert, table.remove
local lpegmatch = lpeg.match
local simple_hash_to_string, settings_to_hash = utilities.parsers.simple_hash_to_string, utilities.parsers.settings_to_hash
@@ -26,11 +27,6 @@ local trace_lists = false trackers.register("structures.lists", function(
local report_lists = logs.reporter("structure","lists")
-local context = context
-local commands = commands
-
-local texgetcount = tex.getcount
-
local structures = structures
local lists = structures.lists
local sections = structures.sections
@@ -126,8 +122,6 @@ function lists.groupindex(name,group)
return groupindex and groupindex[group] or 0
end
--- we could use t (as hash key) in order to check for dup entries
-
function lists.addto(t)
local m = t.metadata
local u = t.userdata
@@ -136,13 +130,12 @@ function lists.addto(t)
end
local numberdata = t.numberdata
local group = numberdata and numberdata.group
- local name = m.name
if not group then
-- forget about it
elseif group == "" then
group, numberdata.group = nil, nil
else
- local groupindex = groupindices[name][group]
+ local groupindex = groupindices[m.name][group]
if groupindex then
numberdata.numbers = cached[groupindex].numberdata.numbers
end
@@ -161,10 +154,7 @@ function lists.addto(t)
setcomponent(t) -- might move to the tex end
end
if group then
- groupindices[name][group] = p
- end
- if trace_lists then
- report_lists("added %a, internal %a",name,p)
+ groupindices[m.name][group] = p
end
return p
end
@@ -191,17 +181,10 @@ end
-- this is the main pagenumber enhancer
-local enhanced = { }
-
function lists.enhance(n)
+ -- todo: symbolic names for counters
local l = cached[n]
- if not l then
- report_lists("enhancing %a, unknown internal",n)
- elseif enhanced[n] then
- if trace_lists then
- report_lists("enhancing %a, name %a, duplicate ignored",n,name)
- end
- else
+ if l then
local metadata = l.metadata
local references = l.references
--
@@ -209,27 +192,23 @@ function lists.enhance(n)
-- save in the right order (happens at shipout)
lists.tobesaved[#lists.tobesaved+1] = l
-- default enhancer (cross referencing)
- references.realpage = texgetcount("realpageno")
+ references.realpage = texcount.realpageno
-- tags
local kind = metadata.kind
local name = metadata.name
- if trace_lists then
- report_lists("enhancing %a, name %a",n,name)
- end
if references then
-- is this used ?
local tag = tags.getid(kind,name)
if tag and tag ~= "?" then
references.tag = tag
end
+ --~ references.listindex = n
end
-- specific enhancer (kind of obsolete)
local enhancer = kind and lists.enhancers[kind]
if enhancer then
enhancer(l)
end
- --
- enhanced[n] = true
return l
end
end
diff --git a/tex/context/base/strc-lst.mkvi b/tex/context/base/strc-lst.mkvi
index 7cef924b7..15a499c8b 100644
--- a/tex/context/base/strc-lst.mkvi
+++ b/tex/context/base/strc-lst.mkvi
@@ -1262,8 +1262,6 @@
% \resetinteractionparameter\c!contrastcolor
\fi}
-\let\strc_lists_set_style_color\strc_lists_set_style_color_normal
-
%D A helper:
\def\strc_lists_limitated_text#text%
diff --git a/tex/context/base/strc-mar.lua b/tex/context/base/strc-mar.lua
index 02d676fb9..7b3ac11e1 100644
--- a/tex/context/base/strc-mar.lua
+++ b/tex/context/base/strc-mar.lua
@@ -12,9 +12,7 @@ if not modules then modules = { } end modules ['strc-mar'] = {
local insert, concat = table.insert, table.concat
local tostring, next, rawget = tostring, next, rawget
local lpegmatch = lpeg.match
-
-local context = context
-local commands = commands
+local match = string.match
local allocate = utilities.storage.allocate
local setmetatableindex = table.setmetatableindex
@@ -24,10 +22,9 @@ local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local traversenodes = nodes.traverse
-
+local traversenodes = node.traverse
local texsetattribute = tex.setattribute
-local texgetbox = tex.getbox
+local texbox = tex.box
local a_marks = attributes.private("structure","marks")
@@ -124,7 +121,7 @@ local function sweep(head,first,last)
end
local list = n.list
if list then
- first, last = sweep(list,first,last)
+ first, last = sweep(list, first, last)
end
end
end
@@ -138,7 +135,7 @@ setmetatableindex(classes, function(t,k) local s = settings_to_array(k) t[k] = s
local lasts = { }
function marks.synchronize(class,n,option)
- local box = texgetbox(n)
+ local box = texbox[n]
if box then
local first, last = sweep(box.list,0,0)
if option == v_keep and first == 0 and last == 0 then
@@ -154,16 +151,11 @@ function marks.synchronize(class,n,option)
for i=1,#classlist do
local class = classlist[i]
local range = ranges[class]
- if range then
- range.first = first
- range.last = last
- else
- range = {
- first = first,
- last = last,
- }
+ if not range then
+ range = { }
ranges[class] = range
end
+ range.first, range.last = first, last
if trace_marks_get or trace_marks_set then
report_marks("action %a, class %a, first %a, last %a","synchronize",class,range.first,range.last)
end
@@ -667,10 +659,8 @@ function marks.fetchallmarks(name,range) fetchallmarks(name,range )
-- here we have a few helpers .. will become commands.*
-local pattern = lpeg.afterprefix("li::")
-
function marks.title(tag,n)
- local listindex = lpegmatch(pattern,n)
+ local listindex = match(n,"^li::(.-)$")
if listindex then
commands.savedlisttitle(tag,listindex,"marking")
else
@@ -679,7 +669,7 @@ function marks.title(tag,n)
end
function marks.number(tag,n) -- no spec
- local listindex = lpegmatch(pattern,n)
+ local listindex = match(n,"^li::(.-)$")
if listindex then
commands.savedlistnumber(tag,listindex)
else
diff --git a/tex/context/base/strc-not.lua b/tex/context/base/strc-not.lua
index 40b78d59f..882e00a44 100644
--- a/tex/context/base/strc-not.lua
+++ b/tex/context/base/strc-not.lua
@@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['strc-not'] = {
local format = string.format
local next = next
+local texcount = tex.count
local trace_notes = false trackers.register("structures.notes", function(v) trace_notes = v end)
local trace_references = false trackers.register("structures.notes.references", function(v) trace_references = v end)
@@ -23,9 +24,6 @@ local notes = structures.notes
local references = structures.references
local counterspecials = counters.specials
-local texgetcount = tex.getcount
-local texgetbox = tex.getbox
-
notes.states = notes.states or { }
lists.enhancers = lists.enhancers or { }
@@ -93,10 +91,10 @@ end
local function getn(tag)
local nd = notedata[tag]
- return nd and #nd or 0
+ return (nd and #nd) or 0
end
-notes.get = get
+notes.get = get
notes.getn = getn
-- we could make a special enhancer
@@ -191,7 +189,7 @@ local function hascontent(tag)
local ok = notestates[tag]
if ok then
if ok.kind == "insert" then
- ok = texgetbox(ok.number)
+ ok = tex.box[ok.number]
if ok then
ok = tbs.list
ok = lst and lst.next
@@ -259,7 +257,7 @@ function notes.checkpagechange(tag) -- called before increment !
end
elseif current then
-- we need to locate the next one, best guess
- if texgetcount("realpageno") > current.pagenumber.number then
+ if texcount.realpageno > current.pagenumber.number then
counters.reset(tag)
end
end
@@ -282,7 +280,7 @@ commands.postponenotes = notes.postpone
function notes.setsymbolpage(tag,n,l)
local l = l or listindex(tag,n)
if l then
- local p = texgetcount("realpageno")
+ local p = texcount.realpageno
if trace_notes or trace_references then
report_notes("note %a of %a with list index %a gets symbol page %a",n,tag,l,p)
end
@@ -384,7 +382,7 @@ function commands.flushnotes(tag,whatkind,how) -- store and postpone
local rp = get(tag,i)
rp = rp and rp.references
rp = rp and rp.symbolpage or 0
- if rp > texgetcount("realpageno") then
+ if rp > texcount.realpageno then
state.start = i
return
end
diff --git a/tex/context/base/strc-not.mkvi b/tex/context/base/strc-not.mkvi
index cf1735da8..76816d035 100644
--- a/tex/context/base/strc-not.mkvi
+++ b/tex/context/base/strc-not.mkvi
@@ -622,15 +622,8 @@
\unexpanded\def\strc_notes_inject_symbol_nop
{\strc_notes_inject_symbol_indeed\conditionalfalse}
-% % this flushes the data to the list
-%
-% \unexpanded\def\strc_notes_inject_symbol_snc
-% {\currentconstructionsynchronize}
-%
-% but instead we need to do this with the content
-
-\unexpanded\def\strc_notes_inject_symbol_snc % so this will go away probably
- {}
+\unexpanded\def\strc_notes_inject_symbol_snc
+ {\currentconstructionsynchronize} % this flushes the data to the list
\unexpanded\def\strc_notes_inject_symbol_indeed#synchronize%
{\removeunwantedspaces
@@ -1177,17 +1170,16 @@
\usesetupsparameter\noteparameter % experimental
\doifelse{\noteparameter\c!paragraph}\v!yes
{\nointerlineskip
- \vboxtohboxslack.5\emwidth % we can instead use \hboxestohboxslack later
\startvboxtohbox
- \handlenoteitself{#tag}{#id}%
- \strc_notes_between_paragraphs
+ \handlenoteitself{#tag}{#id}%
+ % add some slack
\stopvboxtohbox}
{\handlenoteitself{#tag}{#id}}%
\egroup
\the\everyafternoteinsert
\endgroup}
-\unexpanded\def\betweennoteitself#tag% used ?
+\unexpanded\def\betweennoteitself#tag%
{\edef\currentnote{#tag}%
\doif{\noteparameter\c!paragraph}\v!yes\strc_notes_between_paragraphs}
@@ -1200,7 +1192,7 @@
% as we can have collected notes (e.g. in tables) we need to recover
% \currentdescriptionattribute and \currentdescriptionsynchronize
%
- \reinstateconstructionnumberentry\currentconstructionlistentry % we could store the number in the entry (e.g. needed when local notes in table)
+ %\reinstateconstructionnumberentry\currentconstructionlistentry % we could store the number in the entry
%
\dontcomplain
% \begingroup
@@ -1346,11 +1338,18 @@
\def\strc_notes_between_paragraphs_first
{\glet\strc_notes_between_paragraphs_indeed\strc_notes_between_paragraphs}% shape works reverse
-\def\strc_notes_flush_global
+\def\strc_notes_flush_global % will be done in lua instead
{\doifelse{\noteparameter\c!paragraph}\v!yes
- {\vbox\starthboxestohbox
- \iftrialtypesetting\unvcopy\else\unvbox\fi\currentnoteinsertionnumber
- \stophboxestohbox}
+ {\vbox
+ {\beginofshapebox
+ \iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteinsertionnumber
+ \endofshapebox
+ \let\strc_notes_between_paragraphs_indeed\strc_notes_between_paragraphs_first % shape works reverse
+ \doreshapebox
+ {\hbox{\unhbox\shapebox\strc_notes_between_paragraphs_indeed}}
+ \donothing \donothing \donothing % get rid of penalties etc
+ \innerflushshapebox
+ \convertvboxtohbox}}
{\iftrialtypesetting\unvcopied\else\unvboxed\fi\currentnoteinsertionnumber}}
%D Supporting end notes is surprisingly easy. Even better, we
diff --git a/tex/context/base/strc-num.lua b/tex/context/base/strc-num.lua
index 67e9b1734..b0eae6b78 100644
--- a/tex/context/base/strc-num.lua
+++ b/tex/context/base/strc-num.lua
@@ -9,7 +9,7 @@ if not modules then modules = { } end modules ['strc-num'] = {
local format = string.format
local next, type = next, type
local min, max = math.min, math.max
-local texsetcount = tex.setcount
+local texcount, texsetcount = tex.count, tex.setcount
-- Counters are managed here. They can have multiple levels which makes it easier to synchronize
-- them. Synchronization is sort of special anyway, as it relates to document structuring.
@@ -147,9 +147,9 @@ local function dummyconstructor(t,name,i)
end
setmetatableindex(constructor,function(t,k)
- -- if trace_counters then
- -- report_counters("unknown constructor %a",k)
- -- end
+ if trace_counters then
+ report_counters("unknown constructor %a",k)
+ end
return dummyconstructor
end)
diff --git a/tex/context/base/strc-pag.lua b/tex/context/base/strc-pag.lua
index 02ed5610f..f70d37d63 100644
--- a/tex/context/base/strc-pag.lua
+++ b/tex/context/base/strc-pag.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['strc-pag'] = {
license = "see context related readme files"
}
+local texcount = tex.count
+
local allocate, mark = utilities.storage.allocate, utilities.storage.mark
local trace_pages = false trackers.register("structures.pages", function(v) trace_pages = v end)
@@ -24,16 +26,12 @@ local counterdata = counters.data
local variables = interfaces.variables
local context = context
-local commands = commands
local processors = typesetters.processors
local applyprocessor = processors.apply
local startapplyprocessor = processors.startapply
local stopapplyprocessor = processors.stopapply
-local texsetcount = tex.setcount
-local texgetcount = tex.getcount
-
-- storage
local collected, tobesaved = allocate(), allocate()
@@ -51,8 +49,7 @@ job.register('structures.pages.collected', tobesaved, initializer)
local specification = { } -- to be checked
function pages.save(prefixdata,numberdata)
- local realpage = texgetcount("realpageno")
- local userpage = texgetcount("userpageno")
+ local realpage, userpage = texcount.realpageno, texcount.userpageno
if realpage > 0 then
if trace_pages then
report_pages("saving page %s.%s",realpage,userpage)
@@ -76,24 +73,24 @@ end
-- builder we have to make sure it starts at least at 1.
function counters.specials.userpage()
- local r = texgetcount("realpageno")
+ local r = texcount.realpageno
if r > 0 then
local t = tobesaved[r]
if t then
- t.number = texgetcount("userpageno")
+ t.number = texcount.userpageno
if trace_pages then
report_pages("forcing pagenumber of realpage %s to %s",r,t.number)
end
return
end
end
- local u = texgetcount("userpageno")
+ local u = texcount.userpageno
if u == 0 then
if trace_pages then
report_pages("forcing pagenumber of realpage %s to %s (probably a bug)",r,1)
end
counters.setvalue("userpage",1)
- texsetcount("userpageno",1) -- not global ?
+ texcount.userpageno = 1
end
end
@@ -255,8 +252,8 @@ function helpers.prefix(data,prefixspec)
end
function pages.is_odd(n)
- n = n or texgetcount("realpageno")
- if texgetcount("pagenoshift") % 2 == 0 then
+ n = n or texcount.realpageno
+ if texcount.pagenoshift % 2 == 0 then
return n % 2 == 0
else
return n % 2 ~= 0
diff --git a/tex/context/base/strc-ref.lua b/tex/context/base/strc-ref.lua
index 9b4ec6ab7..284418c48 100644
--- a/tex/context/base/strc-ref.lua
+++ b/tex/context/base/strc-ref.lua
@@ -15,10 +15,10 @@ if not modules then modules = { } end modules ['strc-ref'] = {
-- todo: autoload components when :::
local format, find, gmatch, match, concat = string.format, string.find, string.gmatch, string.match, table.concat
-local floor = math.floor
+local texcount, texsetcount = tex.count, tex.setcount
local rawget, tonumber = rawget, tonumber
local lpegmatch = lpeg.match
-local insert, remove, copytable = table.insert, table.remove, table.copy
+local copytable = table.copy
local formatters = string.formatters
local allocate = utilities.storage.allocate
@@ -46,17 +46,16 @@ local report_empty = logs.reporter("references","empty")
local variables = interfaces.variables
local constants = interfaces.constants
local context = context
-local commands = commands
-
-local texgetcount = tex.getcount
-local texsetcount = tex.setcount
-local texconditionals = tex.conditionals
local v_default = variables.default
local v_url = variables.url
local v_file = variables.file
local v_unknown = variables.unknown
local v_yes = variables.yes
+
+local texcount = tex.count
+local texconditionals = tex.conditionals
+
local productcomponent = resolvers.jobs.productcomponent
local justacomponent = resolvers.jobs.justacomponent
@@ -141,10 +140,16 @@ job.register('structures.references.collected', tobesaved, initializer, finalize
local maxreferred = 1
local nofreferred = 0
+-- local function initializer() -- can we use a tobesaved as metatable for collected?
+-- tobereferred = references.tobereferred
+-- referred = references.referred
+-- nofreferred = #referred
+-- end
+
local function initializer() -- can we use a tobesaved as metatable for collected?
tobereferred = references.tobereferred
referred = references.referred
- nofreferred = #referred
+ setmetatableindex(referred,get) -- hm, what is get ?
end
-- We make the array sparse (maybe a finalizer should optionally return a table) because
@@ -211,11 +216,9 @@ local function referredpage(n)
end
end
-- fallback
- return texgetcount("realpageno")
+ return texcount.realpageno
end
--- setmetatableindex(referred,function(t,k) return referredpage(k) end )
-
references.referredpage = referredpage
function references.registerpage(n) -- called in the backend code
@@ -223,7 +226,7 @@ function references.registerpage(n) -- called in the backend code
if n > maxreferred then
maxreferred = n
end
- tobereferred[n] = texgetcount("realpageno")
+ tobereferred[n] = texcount.realpageno
end
end
@@ -249,7 +252,7 @@ references.setnextorder = setnextorder
function references.setnextinternal(kind,name)
setnextorder(kind,name) -- always incremented with internal
- local n = texgetcount("locationcount") + 1
+ local n = texcount.locationcount + 1
texsetcount("global","locationcount",n)
return n
end
@@ -308,7 +311,7 @@ end
function references.enhance(prefix,tag)
local l = tobesaved[prefix][tag]
if l then
- l.references.realpage = texgetcount("realpageno")
+ l.references.realpage = texcount.realpageno
end
end
@@ -1381,36 +1384,25 @@ local function identify_inner_or_outer(set,var,i)
return v
end
- -- these get auto prefixes but are loaded in the document so they are
- -- internal .. we also set the realpage (for samepage analysis)
+local components = job.structure.components
- local components = job.structure.components
- if components then
- for i=1,#components do
- local component = components[i]
- local data = collected[component]
- local vi = data and data[inner]
- if vi then
--- var = copytable(var)
--- var.kind = "inner"
--- var.i = vi
--- var.p = component
--- runners.inner(var.r = vi.references.realpage
--- if trace_identifying then
--- report_identify_outer(set,var,i,"4x")
--- end
--- return var
-local v = identify_inner(set,copytable(var),component,collected) -- is copy needed ?
-if v.i and not v.error then
- v.kind = "inner"
- if trace_identifying then
- report_identify_outer(set,var,i,"4x")
- end
- return v
-end
- end
+if components then
+ for i=1,#components do
+ local component = components[i]
+ local data = collected[component]
+ local vi = data and data[inner]
+ if vi then
+ var.outer = component
+ var.i = vi
+ var.kind = "outer with inner"
+ set.external = true
+ if trace_identifying then
+ report_identify_outer(set,var,i,"4x")
end
+ return var
end
+ end
+end
local componentreferences = productdata.componentreferences
local productreferences = productdata.productreferences
@@ -1555,7 +1547,7 @@ local function identify(prefix,reference)
end
local set = resolve(prefix,reference)
local bug = false
- texsetcount("referencehastexstate",set.has_tex and 1 or 0)
+ texcount.referencehastexstate = set.has_tex and 1 or 0
nofidentified = nofidentified + 1
set.n = nofidentified
for i=1,#set do
@@ -1683,14 +1675,14 @@ function references.setinternalreference(prefix,tag,internal,view) -- needs chec
t[tn] = "aut:" .. internal
end
local destination = references.mark(t,nil,nil,view) -- returns an attribute
- texsetcount("lastdestinationattribute",destination)
+ texcount.lastdestinationattribute = destination
return destination
end
end
function references.setandgetattribute(kind,prefix,tag,data,view) -- maybe do internal automatically here
local attr = references.set(kind,prefix,tag,data) and references.setinternalreference(prefix,tag,nil,view) or unsetvalue
- texsetcount("lastdestinationattribute",attr)
+ texcount.lastdestinationattribute = attr
return attr
end
@@ -1809,7 +1801,7 @@ function filters.generic.number(data,what,prefixspec) -- todo: spec and then no
sections.typesetnumber(numberdata,"number",numberdata)
else
local useddata = data.useddata
- if useddata and useddata.number then
+ if useddata and useddsta.number then
context(useddata.number)
end
end
@@ -1939,8 +1931,7 @@ local specials = references.testspecials
-- real page to determine if we need contrastlocation as that is more lightweight.
local function checkedpagestate(n,page)
- local r = referredpage(n)
- local p = tonumber(page)
+ local r, p = referredpage(n), tonumber(page)
if not p then
return 0
elseif p > r then
@@ -1953,9 +1944,7 @@ local function checkedpagestate(n,page)
end
local function setreferencerealpage(actions)
- if not actions then
- actions = references.currentset
- end
+ actions = actions or references.currentset
if not actions then
return 0
else
@@ -1987,9 +1976,7 @@ end
-- normally such an analysis happens in the backend code
function references.analyze(actions)
- if not actions then
- actions = references.currentset
- end
+ actions = actions or references.currentset
if not actions then
actions = { realpage = 0, pagestate = 0 }
elseif actions.pagestate then
@@ -2008,15 +1995,12 @@ function references.analyze(actions)
end
function commands.referencepagestate(actions)
- if not actions then
- actions = references.currentset
- end
+ actions = actions or references.currentset
if not actions then
context(0)
else
if not actions.pagestate then
references.analyze(actions) -- delayed unless explicitly asked for
--- print("NO STATE",actions.reference,actions.pagestate)
end
context(actions.pagestate)
end
@@ -2035,10 +2019,7 @@ local function realpageofpage(p) -- the last one counts !
nofrealpages = #pages
plist = { }
for rp=1,nofrealpages do
- local page = pages[rp]
- if page then
- plist[page.number] = rp
- end
+ plist[pages[rp].number] = rp
end
references.nofrealpages = nofrealpages
end
@@ -2052,7 +2033,7 @@ function references.checkedrealpage(r)
realpageofpage(r) -- just initialize
end
if not r then
- return texgetcount("realpageno")
+ return texcount.realpageno
elseif r < 1 then
return 1
elseif r > nofrealpages then
@@ -2145,7 +2126,7 @@ end
function specials.deltapage(var,actions)
local p = tonumber(var.operation)
if p then
- p = references.checkedrealpage(p + texgetcount("realpageno"))
+ p = references.checkedrealpage(p + texcount.realpageno)
var.r = p
actions.realpage = actions.realpage or p -- first wins
end
@@ -2175,23 +2156,3 @@ function references.import(usedname) end
function references.load (usedname) end
commands.exportreferences = references.export
-
--- better done here .... we don't insert/remove, just use a pointer
-
-local prefixstack = { "" }
-local prefixlevel = 1
-
-function commands.pushreferenceprefix(prefix)
- prefixlevel = prefixlevel + 1
- prefixstack[prefixlevel] = prefix
- context(prefix)
-end
-
-function commands.popreferenceprefix()
- prefixlevel = prefixlevel - 1
- if prefixlevel > 0 then
- context(prefixstack[prefixlevel])
- else
- report_references("unable to pop referenceprefix")
- end
-end
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index 69ad4629e..c82a09d20 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -75,8 +75,6 @@
%D document). By setting the \type{interaction} variable, one
%D can influences the way interactive references are set.
-\let\referenceprefix\empty
-
\installcorenamespace{referencing}
\installdirectcommandhandler \??referencing {referencing} % \??referencing
@@ -232,7 +230,6 @@
\dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute\bgroup
\strc_references_flush_destination_nodes
\egroup
- \prewordbreak % new
\fi}
\def\strc_references_set_page_only_destination_attribute#labels% could in fact be fully expandable
@@ -774,24 +771,12 @@
\unexpanded\def\setupglobalreferenceprefix[#prefix]%
{\xdef\referenceprefix{#prefix}}
-% \unexpanded\def\pushreferenceprefix#prefix%
-% {\pushmacro\referenceprefix
-% \xdef\referenceprefix{#prefix}} % global
-
-% \unexpanded\def\popreferenceprefix
-% {\popmacro\referenceprefix}
-
-\unexpanded\def\globalpushreferenceprefix#prefix%
- {\xdef\referenceprefix{\ctxcommand{pushreferenceprefix("#prefix")}}}
-
-\unexpanded\def\globalpopreferenceprefix
- {\xdef\referenceprefix{\ctxcommand{popreferenceprefix()}}}
-
\unexpanded\def\pushreferenceprefix#prefix%
- {\edef\referenceprefix{\ctxcommand{pushreferenceprefix("#prefix")}}}
+ {\pushmacro\referenceprefix
+ \xdef\referenceprefix{#prefix}}
\unexpanded\def\popreferenceprefix
- {\edef\referenceprefix{\ctxcommand{popreferenceprefix()}}}
+ {\popmacro\referenceprefix}
\def\m_strc_references_prefix_yes{+}
\def\m_strc_references_prefix_nop{-}
@@ -814,7 +799,7 @@
\fi\fi\fi\fi}
\appendtoks
- \setupreferenceprefix[\referencingparameter\c!prefix]
+ \setupreferenceprefix[\referencingparameter\c!prefix]
\to \everysetupreferencing
%D We can typeset a reference using \type{\in}, \type{\at} and
diff --git a/tex/context/base/strc-reg.lua b/tex/context/base/strc-reg.lua
index b0d8a8a25..40cd3455b 100644
--- a/tex/context/base/strc-reg.lua
+++ b/tex/context/base/strc-reg.lua
@@ -7,41 +7,36 @@ if not modules then modules = { } end modules ['strc-reg'] = {
}
local next, type = next, type
+local texcount = tex.count
local format, gmatch = string.format, string.gmatch
local equal, concat, remove = table.are_equal, table.concat, table.remove
local utfchar = utf.char
local lpegmatch = lpeg.match
local allocate = utilities.storage.allocate
-local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end)
+local trace_registers = false trackers.register("structures.registers", function(v) trace_registers = v end)
-local report_registers = logs.reporter("structure","registers")
+local report_registers = logs.reporter("structure","registers")
-local structures = structures
-local registers = structures.registers
-local helpers = structures.helpers
-local sections = structures.sections
-local documents = structures.documents
-local pages = structures.pages
-local references = structures.references
+local structures = structures
+local registers = structures.registers
+local helpers = structures.helpers
+local sections = structures.sections
+local documents = structures.documents
+local pages = structures.pages
+local references = structures.references
-local mappings = sorters.mappings
-local entries = sorters.entries
-local replacements = sorters.replacements
+local mappings = sorters.mappings
+local entries = sorters.entries
+local replacements = sorters.replacements
-local processors = typesetters.processors
-local splitprocessor = processors.split
+local processors = typesetters.processors
+local splitprocessor = processors.split
-local texgetcount = tex.getcount
+local variables = interfaces.variables
+local context = context
-local variables = interfaces.variables
-local context = context
-local commands = commands
-
-local matchingtilldepth = sections.matchingtilldepth
-local numberatdepth = sections.numberatdepth
-
-local absmaxlevel = 5 -- \c_strc_registers_maxlevel
+local matchingtilldepth, numberatdepth = sections.matchingtilldepth, sections.numberatdepth
-- some day we will share registers and lists (although there are some conceptual
-- differences in the application of keywords)
@@ -291,7 +286,7 @@ end
function registers.enhance(name,n)
local r = tobesaved[name].entries[n]
if r then
- r.references.realpage = texgetcount("realpageno")
+ r.references.realpage = texcount.realpageno
end
end
@@ -303,7 +298,7 @@ function registers.extend(name,tag,rawdata) -- maybe do lastsection internally
local r = tobesaved[name].entries[tag]
if r then
local rr = r.references
- rr.lastrealpage = texgetcount("realpageno")
+ rr.lastrealpage = texcount.realpageno
rr.lastsection = sections.currentid()
if rawdata then
if rawdata.entries then
@@ -668,31 +663,11 @@ function registers.flush(data,options,prefixspec,pagespec)
local collapse_singles = options.compress == variables.yes
local collapse_ranges = options.compress == variables.all
local result = data.result
- local maxlevel = 0
- --
- for i=1,#result do
- local data = result[i].data
- for d=1,#data do
- local m = #data[d].list
- if m > maxlevel then
- maxlevel = m
- end
- end
- end
- if maxlevel > absmaxlevel then
- maxlevel = absmaxlevel
- report_registers("limiting level to %a",maxlevel)
- end
- --
context.startregisteroutput()
-local done = { }
for i=1,#result do
-- ranges need checking !
local sublist = result[i]
- -- local done = { false, false, false, false }
-for i=1,maxlevel do
- done[i] = false
-end
+ local done = { false, false, false, false }
local data = sublist.data
local d, n = 0, 0
context.startregistersection(sublist.tag)
@@ -708,28 +683,20 @@ end
end
end
end
- -- ok, this is tricky: we use e[i] delayed so we need it to be local
- -- but we don't want to allocate too many entries so there we go
while d < #data do
d = d + 1
local entry = data[d]
- local e = { false, false, false }
-for i=3,maxlevel do
- e[i] = false
-end
+ local e = { false, false, false, false }
local metadata = entry.metadata
local kind = metadata.kind
local list = entry.list
- for i=1,maxlevel do
+ for i=1,4 do -- max 4
if list[i] then
e[i] = list[i][1]
end
if e[i] ~= done[i] then
if e[i] and e[i] ~= "" then
done[i] = e[i]
-for j=i+1,maxlevel do
- done[j] = false
-end
if n == i then
context.stopregisterentries()
context.startregisterentries(n)
@@ -746,8 +713,6 @@ end
local internal = entry.references.internal or 0
local seeparent = entry.references.seeparent or ""
local processor = entry.processors and entry.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
if metadata then
context.registerentry(processor,internal,seeparent,function() helpers.title(e[i],metadata) end)
else -- ?
@@ -755,9 +720,6 @@ end
end
else
done[i] = false
-for j=i+1,maxlevel do
- done[j] = false
-end
end
end
end
@@ -888,7 +850,6 @@ end
data.metadata.sorted = false
end
-
function registers.analyze(class,options)
context(registers.analyzed(class,options))
end
diff --git a/tex/context/base/strc-reg.mkiv b/tex/context/base/strc-reg.mkiv
index febb4c0b0..8c9f040f0 100644
--- a/tex/context/base/strc-reg.mkiv
+++ b/tex/context/base/strc-reg.mkiv
@@ -116,7 +116,6 @@
%D \stoptyping
\newconditional\c_strc_registers_defining
-\setnewconstant\c_strc_registers_maxlevel \plusfive
\ifdefined\Word \else \unexpanded\def\Word#1{#1} \fi
@@ -132,7 +131,7 @@
\setuevalue{\e!place\currentregister}{\placeregister[\currentregister]}%
\setuevalue{\e!complete\currentregister}{\completeregister[\currentregister]}%
\setuevalue{\e!setup\currentregister\e!endsetup}{\setupregister[\currentregister]}%
- \dorecurse\c_strc_registers_maxlevel{% weird, expanded should not be needed
+ \dorecurse\plusthree {% weird, expanded should not be needed
\normalexpanded{\defineregister[\currentregister:\recurselevel][\currentregister]}%
%\defineregister[\currentregister:\recurselevel][\currentregister]%
\letregisterparameter{\c!entries:\recurselevel}\empty % needed as we use detokenize (ok, we can
@@ -673,29 +672,14 @@
\dostoptagged
\endgroup}
-% \unexpanded\def\startregisterentries#1% depth
-% {\endgraf
-% \begingroup
-% \dostarttagged\t!registerentries\empty
-% \let\savedcurrentregister\currentregister
-% \edef\currentregister{\currentregister:#1}%
-% \useregisterstyleandcolor\c!textstyle\c!textcolor
-% \advance\leftskip\numexpr#1-\plusone\relax\dimexpr\d_strc_registers_distance\relax
-% \hangindent\registerparameter\c!distance\relax
-% \hangafter\plusone
-% \let\currentregister\savedcurrentregister}
-
\unexpanded\def\startregisterentries#1% depth
{\endgraf
\begingroup
- \scratchcounter\ifnum#1>\c_strc_registers_maxlevel\c_strc_registers_maxlevel\else#1\fi\relax
\dostarttagged\t!registerentries\empty
\let\savedcurrentregister\currentregister
- \edef\currentregister{\currentregister:\number\scratchcounter}%
+ \edef\currentregister{\currentregister:#1}%
\useregisterstyleandcolor\c!textstyle\c!textcolor
- \ifnum\scratchcounter>\plusone
- \advance\leftskip\d_strc_registers_distance\relax
- \fi
+ \advance\leftskip\numexpr#1-\plusone\relax\dimexpr\d_strc_registers_distance\relax
\hangindent\registerparameter\c!distance\relax
\hangafter\plusone
\let\currentregister\savedcurrentregister}
diff --git a/tex/context/base/strc-ren.mkiv b/tex/context/base/strc-ren.mkiv
index fdf8fb7f4..00c8c3cd4 100644
--- a/tex/context/base/strc-ren.mkiv
+++ b/tex/context/base/strc-ren.mkiv
@@ -26,7 +26,7 @@
% \def\doTitle#1#2{\ruledvbox{\forgetall \hsize=4cm \ruledhbox{\ruledvtop{#1}\ruledvtop{#2}}}}
% \section{test test test test test test test test test test test test test test test test test}
-% \newtoks\everyheadstart % not used currently
+\newtoks\everyheadstart
\unexpanded\def\strc_rendering_initialize_style_and_color
{\ifconditional\headisdisplay
@@ -625,16 +625,10 @@
\dontleavehmode % in case there is no strut, else side effects with llap
\ifconditional\headshownumber
\llap {
- \signalrightpage
\hbox {
\hfill
\headnumbercontent
- \doifrightpageelse{
- \scratchdistance\leftmargindistance
- } {
- \scratchdistance\rightmargindistance
- }
- \hskip\dimexpr\d_strc_rendering_local_leftoffset+\scratchdistance\relax
+ \hskip\dimexpr\d_strc_rendering_local_leftoffset+\doifoddpageelse\leftmargindistance\rightmargindistance\relax
}
}
\fi
diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv
index 2836b018b..a5ff2084e 100644
--- a/tex/context/base/strc-sec.mkiv
+++ b/tex/context/base/strc-sec.mkiv
@@ -432,9 +432,6 @@
\unexpanded\def\startnamedsection
{\dotripleempty\strc_sectioning_start_named_section}
-% todo: add grouping but where: before/after trickery .. probably inside because one can always add
-% grouping to the before/after settings
-
\unexpanded\def\strc_sectioning_start_named_section[#1]% [#2][#3]
{\pushmacro\currentnamedsection
\edef\currentnamedsection{#1}%
@@ -591,13 +588,11 @@
\headparameter\c!beforesection % beware, no users vars set yet
\the\everybeforehead
\strc_sectioning_handle{#1}{#2}{#3}% name -- -- -- userdata (we might move the tagged to here)
- % potential: \bgroup (can be optional: grouped = yes)
\headparameter\c!insidesection}
\unexpanded\def\strc_sectioning_stop[#1]% !!! also used at lua end
{\dostoptagged
\dostoptagged
- % potential: \egroup
%\globalpopmacro\currenthead % so we do a hard recover
\xdef\currenthead{#1}% recover
\headparameter\c!aftersection
@@ -686,15 +681,8 @@
\setfalse\headshownumber
\fi}
-\newtoks\everyheadsynchronization
-
-\appendtoks
- \currentstructuresynchronize
-\to \everyheadsynchronization
-
\unexpanded\def\theheadsynchonization
- {\the\everyheadsynchronization
- \currentstructuresynchronize}
+ {\currentstructuresynchronize}
% BEWARE: \marking[section]{my text} does not work as we use list indices instead
% so we need a 'keep track of raw set option' (or maybe a funny internal prefix)
diff --git a/tex/context/base/supp-box.lua b/tex/context/base/supp-box.lua
index bc0a7056e..c7382834a 100644
--- a/tex/context/base/supp-box.lua
+++ b/tex/context/base/supp-box.lua
@@ -6,16 +6,12 @@ if not modules then modules = { } end modules ['supp-box'] = {
license = "see context related readme files"
}
--- this is preliminary code, use insert_before etc
+-- this is preliminary code
local report_hyphenation = logs.reporter("languages","hyphenation")
-local tex = tex
-local context = context
-local commands = commands
-local nodes = nodes
-
-local splitstring = string.split
+local tex, node = tex, node
+local context, commands, nodes = context, commands, nodes
local nodecodes = nodes.nodecodes
@@ -26,17 +22,11 @@ local glue_code = nodecodes.glue
local glyph_code = nodecodes.glyph
local new_penalty = nodes.pool.penalty
-local new_hlist = nodes.pool.hlist
-local new_glue = nodes.pool.glue
-
-local free_node = nodes.free
-local copy_list = nodes.copy_list
-local copy_node = nodes.copy
-local find_tail = nodes.tail
-local texsetbox = tex.setbox
-local texgetbox = tex.getbox
-local texget = tex.get
+local free_node = node.free
+local copynodelist = node.copy_list
+local copynode = node.copy
+local texbox = tex.box
local function hyphenatedlist(list)
while list do
@@ -66,7 +56,7 @@ end
local function checkedlist(list)
if type(list) == "number" then
- return texgetbox(list).list
+ return texbox[list].list
else
return list
end
@@ -83,9 +73,9 @@ local function applytochars(list,what,nested)
applytochars(current.list,what,nested)
context.endhbox()
elseif id ~= glyph_code then
- noaction(copy_node(current))
+ noaction(copynode(current))
else
- doaction(copy_node(current))
+ doaction(copynode(current))
end
current = current.next
end
@@ -100,10 +90,10 @@ local function applytowords(list,what,nested)
local id = current.id
if id == glue_code then
if start then
- doaction(copy_list(start,current))
+ doaction(copynodelist(start,current))
start = nil
end
- noaction(copy_node(current))
+ noaction(copynode(current))
elseif nested and (id == hlist_code or id == vlist_code) then
context.beginhbox()
applytowords(current.list,what,nested)
@@ -114,97 +104,9 @@ local function applytowords(list,what,nested)
current = current.next
end
if start then
- doaction(copy_list(start))
+ doaction(copynodelist(start))
end
end
commands.applytochars = applytochars
commands.applytowords = applytowords
-
-local split_char = lpeg.Ct(lpeg.C(1)^0)
-local split_word = lpeg.tsplitat(lpeg.patterns.space)
-local split_line = lpeg.tsplitat(lpeg.patterns.eol)
-
-function commands.processsplit(str,command,how,spaced)
- how = how or "word"
- if how == "char" then
- local words = lpeg.match(split_char,str)
- for i=1,#words do
- local word = words[i]
- if word == " " then
- if spaced then
- context.space()
- end
- elseif command then
- context[command](word)
- else
- context(word)
- end
- end
- elseif how == "word" then
- local words = lpeg.match(split_word,str)
- for i=1,#words do
- local word = words[i]
- if spaced and i > 1 then
- context.space()
- end
- if command then
- context[command](word)
- else
- context(word)
- end
- end
- elseif how == "line" then
- local words = lpeg.match(split_line,str)
- for i=1,#words do
- local word = words[i]
- if spaced and i > 1 then
- context.par()
- end
- if command then
- context[command](word)
- else
- context(word)
- end
- end
- else
- context(str)
- end
-end
-
-function commands.vboxlisttohbox(original,target,inbetween)
- local current = texgetbox(original).list
- local head = nil
- local tail = nil
- while current do
- if current.id == hlist_code then
- local list = current.list
- if head then
- if inbetween > 0 then
- local n = new_glue(0,0,inbetween)
- tail.next = n
- n.prev = tail
- tail = n
- end
- tail.next = list
- list.prev = tail
- else
- head = list
- end
- tail = find_tail(list)
- tail.next = nil
- current.list = nil
- end
- current = current.next
- end
- local result = new_hlist()
- result.list = head
- texsetbox(target,result)
-end
-
-function commands.hboxtovbox(original)
- local b = texgetbox(original)
- local factor = texget("baselineskip").width / texget("hsize")
- b.depth = 0
- b.height = b.width * factor
-end
diff --git a/tex/context/base/supp-box.mkiv b/tex/context/base/supp-box.mkiv
index ad35b525b..833096222 100644
--- a/tex/context/base/supp-box.mkiv
+++ b/tex/context/base/supp-box.mkiv
@@ -1346,11 +1346,11 @@
%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{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{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
@@ -1379,15 +1379,7 @@
\let\processword\relax
-\unexpanded\def\applytosplitstringchar#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","char")}}
-\unexpanded\def\applytosplitstringword#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","word")}}
-\unexpanded\def\applytosplitstringline#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","line")}}
-
-\unexpanded\def\applytosplitstringcharspaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","char",true)}}
-\unexpanded\def\applytosplitstringwordspaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","word",true)}}
-\unexpanded\def\applytosplitstringlinespaced#1#2{\dontleavehmode\ctxcommand{processsplit(\!!bs#2\!!es,"\strippedcsname#1","line",true)}}
-
-%D A variant:
+%D The better variant:
\unexpanded\def\applytocharacters#1%
{\dontleavehmode
@@ -1738,56 +1730,35 @@
%D These macros are used in reformatting footnotes, so they do
%D what they're meant for.
-\newdimen\vboxtohboxslack
-\newdimen\hboxestohboxslack
-
-% Create line and fake height of paragraph by messign with heights:
-% a nice hack by 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:
+\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
- \setbox\scratchbox\hbox\bgroup}
+ {\bgroup
+ \setvboxtohbox
+ \setbox\scratchbox\hbox\bgroup}
\unexpanded\def\stopvboxtohbox
- {\ifcase\vboxtohboxslack\else\hskip\zeropoint\!!minus\vboxtohboxslack\fi
- \egroup
- \ctxcommand{hboxtovbox(\number\scratchbox)}%
+ {\egroup
+ \dp\scratchbox\zeropoint
+ \ht\scratchbox\vboxtohboxfactor\wd\scratchbox
\box\scratchbox
\egroup}
-% A possible reconstruction:
-
\unexpanded\def\convertvboxtohbox
- {\makehboxofhboxes
+ {\setvboxtohbox
+ \makehboxofhboxes
\setbox0\hbox{\unhbox0 \removehboxes}%
\noindent\unhbox0\par}
@@ -1805,42 +1776,6 @@
{\removehboxes}\unhbox0
\fi}
-% And one special for notes:
-
-% \unexpanded\def\starthboxestohbox
-% {\bgroup
-% \beginofshapebox}
-%
-% \unexpanded\def\stophboxestohbox
-% {\endofshapebox
-% \doreshapebox
-% {\hbox\bgroup
-% \unhbox\shapebox
-% \ifcase\hboxestohboxslack\else\hskip\zeropoint\!!minus\hboxestohboxslack\fi
-% \egroup}%
-% \donothing
-% \donothing
-% \donothing % get rid of penalties etc
-% \innerflushshapebox
-% \convertvboxtohbox
-% \par
-% \egroup}
-
-% More modern:
-
-\unexpanded\def\starthboxestohbox
- {\bgroup
- \setbox\scratchbox\vbox\bgroup}
-
-\unexpanded\def\stophboxestohbox
- {\egroup
- \ctxcommand{vboxlisttohbox(\number\scratchbox,\number\nextbox,\number\dimexpr\hboxestohboxslack)}%
- \dontleavehmode
- \unhbox\nextbox
- \removeunwantedspaces
- \par
- \egroup}
-
%D \macros
%D {unhhbox}
%D
diff --git a/tex/context/base/symb-ini.lua b/tex/context/base/symb-ini.lua
index 9586338be..deeef667a 100644
--- a/tex/context/base/symb-ini.lua
+++ b/tex/context/base/symb-ini.lua
@@ -6,7 +6,6 @@ if not modules then modules = { } end modules ['symb-ini'] = {
license = "see context related readme files"
}
-local context, commands = context, commands
local variables = interfaces.variables
diff --git a/tex/context/base/syst-aux.lua b/tex/context/base/syst-aux.lua
index 9ef28996a..b0fb8483b 100644
--- a/tex/context/base/syst-aux.lua
+++ b/tex/context/base/syst-aux.lua
@@ -16,8 +16,7 @@ local commands, context = commands, context
local settings_to_array = utilities.parsers.settings_to_array
local format = string.format
local utfsub = utf.sub
-local P, S, C, Cc, Cs, Carg, lpegmatch, utf8char = lpeg.P, lpeg.S, lpeg.C, lpeg.Cc, lpeg.Cs, lpeg.Carg, lpeg.match, lpeg.patterns.utf8char
-
+local P, C, Carg, lpegmatch, utf8char = lpeg.P, lpeg.C, lpeg.Carg, lpeg.match, lpeg.patterns.utf8char
local setvalue = context.setvalue
@@ -29,15 +28,6 @@ function commands.getfirstcharacter(str)
setvalue("remainingcharacters",rest)
end
-function commands.thefirstcharacter(str)
- local first, rest = lpegmatch(pattern,str)
- context(first)
-end
-function commands.theremainingcharacters(str)
- local first, rest = lpegmatch(pattern,str)
- context(rest)
-end
-
local pattern = C(utf8char^-1)
function commands.doiffirstcharelse(chr,str)
@@ -88,23 +78,3 @@ end
-- \gdef\setpercentdimen#1#2%
-- {#1=\ctxcommand{percentageof("#2",\number#1)}\relax}
-
-local spaces = P(" ")^0/""
-
-local pattern = Cs(
- ( 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
- * Cs( (P("##")/"#" + P(1))^0 )
-)
-
-function commands.thetexdefinition(str)
- context(lpegmatch(pattern,str))
-end
diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv
index 97f601cc9..542b132ae 100644
--- a/tex/context/base/syst-aux.mkiv
+++ b/tex/context/base/syst-aux.mkiv
@@ -401,52 +401,7 @@
\expandafter\m_syst_action_nop
\fi}
-%D Here's one for skipping spaces and pars, handy for:
-%D
-%D \starttyping
-%D \hbox
-%D
-%D {a few lines later}
-%D \stoptyping
-
-% \unexpanded\def\assumelongusagecs#1%
-% {\let\m_syst_action#1%
-% \futurelet\nexttoken\syst_helpers_ignore_par_character}
-%
-% \def\syst_helpers_ignore_par_character
-% {\ifx\nexttoken\blankspace
-% \expandafter\syst_helpers_ignore_par_character_blankspace
-% \else
-% \expandafter\syst_helpers_ignore_par_character_followup
-% \fi}
-%
-% \def\syst_helpers_ignore_par_character_followup
-% {\ifx\nexttoken\par
-% \expandafter\syst_helpers_ignore_par_partoken
-% \else
-% \expandafter\m_syst_action
-% \fi}
-%
-% \def\syst_helpers_ignore_par_partoken
-% {\afterassignment\m_syst_action\let\nexttoken}
-
-\unexpanded\def\assumelongusagecs#1% can be relaxed when we have long support in \hbox etc
- {\let\m_syst_action#1%
- \futurelet\nexttoken\syst_helpers_ignore_spacing}
-
-\def\syst_helpers_ignore_spacing
- {\ifx\nexttoken\blankspace
- \singleexpandafter\syst_helpers_ignore_spacing_blankspace
- \else\ifx\nexttoken\par
- \doubleexpandafter\syst_helpers_ignore_spacing_partoken
- \else
- \doubleexpandafter\m_syst_action
- \fi\fi}
-
-\def\syst_helpers_ignore_spacing_partoken\par
- {\futurelet\nexttoken\syst_helpers_ignore_spacing}
-
-%D These macros use some auxiliary macros. Although we were able to program quite
+%D This macro uses 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
@@ -474,9 +429,6 @@
\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
@@ -1291,13 +1243,8 @@
%D complicated arguments, for instance arguments that
%D consist of two or more expandable tokens.
-\let\firstcharacter \empty
-\let\remainingcharacters\empty
-
-\unexpanded\def\getfirstcharacter #1{\ctxcommand{getfirstcharacter(\!!bs#1\!!es)}}
-\unexpanded\def\doiffirstcharelse #1#2{\ctxcommand{doiffirstcharelse(\!!bs#1\!!es,\!!bs#2\!!es)}} % chr str
-\unexpanded\def\thefirstcharacter #1{\ctxcommand{thefirstcharacter(\!!bs#1\!!es)}}
-\unexpanded\def\theremainingcharacters#1{\ctxcommand{theremainingcharacters(\!!bs#1\!!es)}}
+\def\getfirstcharacter #1{\ctxcommand{getfirstcharacter(\!!bs#1\!!es)}}
+\def\doiffirstcharelse#1#2{\ctxcommand{doiffirstcharelse(\!!bs#1\!!es,\!!bs#2\!!es)}} % chr str
%D \macros
%D {doifinstringelse, doifincsnameelse}
@@ -2945,18 +2892,13 @@
%D
%D Trivial:
-\unexpanded\def\letempty #1{\let#1\empty}
-\unexpanded\def\globalletempty#1{\global\let#1\empty}
+\def\letempty #1{\let#1\empty}
+\def\globalletempty#1{\global\let#1\empty}
-\unexpanded\def\letvalueempty #1{\expandafter\let\csname#1\endcsname\empty}
-\unexpanded\def\letgvalueempty#1{\global\expandafter\let\csname#1\endcsname\empty}
-\unexpanded\def\letvaluerelax #1{\expandafter\let\csname#1\endcsname\relax}
-\unexpanded\def\letgvalurelax #1{\global\expandafter\let\csname#1\endcsname\relax}
-
-\unexpanded\def\relaxvalueifundefined#1%
- {\ifcsname#1\endcsname \else
- \expandafter\let\csname#1\endcsname\relax
- \fi}
+\def\letvalueempty #1{\expandafter\let\csname#1\endcsname\empty}
+\def\letgvalueempty#1{\global\expandafter\let\csname#1\endcsname\empty}
+\def\letvaluerelax #1{\expandafter\let\csname#1\endcsname\relax}
+\def\letgvalurelax #1{\global\expandafter\let\csname#1\endcsname\relax}
%D \macros
%D {wait}
@@ -3180,63 +3122,6 @@
\def\s!unexpanded{unexpanded}
-% \bgroup \obeylines
-%
-% \global\let\stoptexdefinition\relax
-%
-% \unexpanded\gdef\starttexdefinition%
-% {\bgroup%
-% \obeylines%
-% \syst_helpers_start_tex_definition}
-%
-% \gdef\syst_helpers_start_tex_definition #1
-% {\catcode\endoflineasciicode\ignorecatcode%
-% \doifinstringelse\letterhash{\detokenize{#1}}\syst_helpers_start_tex_definition_yes\syst_helpers_start_tex_definition_nop#1
-% }
-%
-% \gdef\syst_helpers_start_tex_definition_yes#1 #2
-% {\edef\texdefinitionname{#1}%
-% \ifx\texdefinitionname\s!unexpanded%
-% \expandafter\syst_helpers_start_tex_definition_yes_unexpanded%
-% \else%
-% \expandafter\syst_helpers_start_tex_definition_yes_normal%
-% \fi%
-% {#1}#2
-% }
-%
-% \gdef\syst_helpers_start_tex_definition_yes_unexpanded#1#2 #3
-% #4\stoptexdefinition%
-% {\egroup% #1=unexpanded
-% \unexpanded\expandafter\def\csname#2\endcsname#3{#4}}
-%
-% \gdef\syst_helpers_start_tex_definition_yes_normal#1#2
-% #3\stoptexdefinition%
-% {\egroup%
-% \expandafter\def\csname#1\endcsname#2{#3}}
-%
-% \gdef\syst_helpers_start_tex_definition_nop#1
-% {\syst_helpers_start_tex_definition_nop_indeed{#1}{}}
-%
-% \gdef\syst_helpers_start_tex_definition_nop_indeed#1#2#3\stoptexdefinition%
-% {\egroup%
-% \expandafter\def\csname#1\endcsname{#3}}
-%
-% \egroup
-
-% \starttexdefinition unexpanded test #1
-% [here #1]
-% \stoptexdefinition
-%
-% \starttexdefinition global unexpanded test
-% [here test]
-% \stoptexdefinition
-%
-% \scratchcounter=123
-%
-% \starttexdefinition global unexpanded expanded test #oeps
-% [here #oeps: \the\scratchcounter]
-% \stoptexdefinition
-
\bgroup \obeylines
\global\let\stoptexdefinition\relax
@@ -3244,15 +3129,39 @@
\unexpanded\gdef\starttexdefinition%
{\bgroup%
\obeylines%
- \syst_helpers_start_tex_definition_one}
+ \syst_helpers_start_tex_definition}
-\gdef\syst_helpers_start_tex_definition_one#1
+\gdef\syst_helpers_start_tex_definition #1
{\catcode\endoflineasciicode\ignorecatcode%
- \syst_helpers_start_tex_definition_two{#1}}
+ \doifinstringelse\letterhash{\detokenize{#1}}\syst_helpers_start_tex_definition_yes\syst_helpers_start_tex_definition_nop#1
+ }
+
+\gdef\syst_helpers_start_tex_definition_yes#1 #2
+ {\edef\texdefinitionname{#1}%
+ \ifx\texdefinitionname\s!unexpanded%
+ \expandafter\syst_helpers_start_tex_definition_yes_unexpanded%
+ \else%
+ \expandafter\syst_helpers_start_tex_definition_yes_normal%
+ \fi%
+ {#1}#2
+ }
+
+\gdef\syst_helpers_start_tex_definition_yes_unexpanded#1#2 #3
+ #4\stoptexdefinition%
+ {\egroup% #1=unexpanded
+ \unexpanded\expandafter\def\csname#2\endcsname#3{#4}}
+
+\gdef\syst_helpers_start_tex_definition_yes_normal#1#2
+ #3\stoptexdefinition%
+ {\egroup%
+ \expandafter\def\csname#1\endcsname#2{#3}}
-\gdef\syst_helpers_start_tex_definition_two#1#2\stoptexdefinition%
+\gdef\syst_helpers_start_tex_definition_nop#1
+ {\syst_helpers_start_tex_definition_nop_indeed{#1}{}}
+
+\gdef\syst_helpers_start_tex_definition_nop_indeed#1#2#3\stoptexdefinition%
{\egroup%
- \ctxcommand{thetexdefinition("#1")}{#2}}
+ \expandafter\def\csname#1\endcsname{#3}}
\egroup
@@ -4572,6 +4481,7 @@
{\let\dodogotopar#1%
\redogotopar\par}
+
\unexpanded\def\GetPar
{\expanded
{\dowithpar
diff --git a/tex/context/base/syst-lua.lua b/tex/context/base/syst-lua.lua
index e47041444..ef524c339 100644
--- a/tex/context/base/syst-lua.lua
+++ b/tex/context/base/syst-lua.lua
@@ -10,10 +10,9 @@ local format, find, match, rep = string.format, string.find, string.match, strin
local tonumber = tonumber
local S, lpegmatch, lpegtsplitat = lpeg.S, lpeg.match, lpeg.tsplitat
-commands = commands or { }
-local commands = commands
+local context = context
-local context = context
+commands = commands or { }
function commands.writestatus(...) logs.status(...) end -- overloaded later
diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv
index 242c3d6fe..57134cb53 100644
--- a/tex/context/base/tabl-ntb.mkiv
+++ b/tex/context/base/tabl-ntb.mkiv
@@ -1517,29 +1517,18 @@
{\scratchdimen\tabl_ntb_get_wid\recurselevel\relax
[\recurselevel:\the\scratchdimen]}}}
-% \def\tabl_ntb_char_align
-% {\doifelse{\naturaltablelocalparameter\c!aligncharacter}\v!yes
-% \tabl_ntb_char_align_indeed\gobbletwoarguments}
-
-% \def\tabl_ntb_char_align_indeed#1#2#3% row column data
-% {\edef\alignmentclass{#2}%
-% \edef\alignmentcharacter{\naturaltablelocalparameter\c!alignmentcharacter}%
-% \ifcase\c_tabl_tbl_pass\or
-% \setfirstpasscharacteralign\checkalignment{#3}% {\strut#2\unskip}%
-% \fi % force hsize, so always a second
-% \setsecondpasscharacteralign \checkalignment{#3}% {\strut#2\unskip}%
-% \ignorespaces}
-
\def\tabl_ntb_char_align
{\doifelse{\naturaltablelocalparameter\c!aligncharacter}\v!yes
- \tabl_ntb_char_align_indeed
- \gobbletwoarguments}
+ \tabl_ntb_char_align_indeed\gobbleoneargument}
-\def\tabl_ntb_char_align_indeed#1#2% row column
- {\ifcase\c_tabl_tbl_pass \or
- \setcharacteralign{#2}{\naturaltablelocalparameter\c!alignmentcharacter}%
- \fi
- \signalcharacteralign{#2}{#1}}
+\def\tabl_ntb_char_align_indeed#1#2% column data
+ {\edef\alignmentclass{#1}%
+ \edef\alignmentcharacter{\naturaltablelocalparameter\c!alignmentcharacter}%
+ \ifcase\c_tabl_tbl_pass\or
+ \setfirstpasscharacteralign\checkalignment{#2}% {\strut#2\unskip}%
+ \fi % force hsize, so always a second
+ \setsecondpasscharacteralign \checkalignment{#2}% {\strut#2\unskip}%
+ \ignorespaces}
\unexpanded\def\tabl_ntb_cell_process_a#1#2[#3]#4% grouping added ! ! !
{\bgroup
@@ -1550,7 +1539,7 @@
\tabl_ntb_set_dis{#2}{\the\scratchdimen}%
\fi
\setupcurrentnaturaltablelocal[#3,\c!background=,\c!frame=\v!off]% 25% faster
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop\tabl_ntb_cell_finalize}}%
+ \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop\tabl_ntb_cell_finalize}}%
\scratchdimen\tabl_ntb_get_wid\c_tabl_ntb_col\relax
\ifdim\wd\scratchbox>\scratchdimen
\ifsqueezeTBLspan
@@ -1636,7 +1625,7 @@
\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}}
+ {#1}{#2}[#3]{\tabl_ntb_char_align{#2}{#4}}}
\unexpanded\def\tabl_ntb_cell_process_c
{\tabl_ntb_cell_process_b_c{}}
@@ -1645,7 +1634,7 @@
{\tabl_ntb_setup_cell{#1}{#2}%
\bgroup
\setupcurrentnaturaltablelocal[#3,\c!width=\d_tabl_ntb_width,\c!background=,\c!frame=\v!off]% 25% faster
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop}%
+ \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop}%
\egroup}
\unexpanded\def\tabl_ntb_cell_process_e#1#2[#3]#4%
@@ -1658,7 +1647,7 @@
\else
\setupcurrentnaturaltablelocal[\c!color=,\c!width=\d_tabl_ntb_width,\c!height=\d_tabl_ntb_height]%
\fi
- \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#1}{#2}#4\tabl_ntb_cell_stop}}%
+ \inheritednaturaltablelocalframed{\tabl_ntb_cell_start\tabl_ntb_char_align{#2}{#4}\tabl_ntb_cell_stop}}%
\hskip\tabl_ntb_get_dis{#2}}
\setupTABLE
diff --git a/tex/context/base/tabl-nte.mkiv b/tex/context/base/tabl-nte.mkiv
index af74a2abe..4a9774cb0 100644
--- a/tex/context/base/tabl-nte.mkiv
+++ b/tex/context/base/tabl-nte.mkiv
@@ -102,9 +102,9 @@
\unexpanded\def\startTABLEbody{\dosingleempty\tabl_nte_start_body} \let\stopTABLEbody\relax
\unexpanded\def\startTABLEfoot{\dosingleempty\tabl_nte_start_foot} \let\stopTABLEfoot\relax
-\def\tabl_nte_start_head[#1]#2\stopTABLEhead{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_head}
-\def\tabl_nte_start_next[#1]#2\stopTABLEnext{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_next}
-\def\tabl_nte_start_body[#1]#2\stopTABLEbody{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_body}
-\def\tabl_nte_start_foot[#1]#2\stopTABLEfoot{\appendtoks\tabl_ntb_section[#1]{#2}\to\t_tabl_ntb_foot}
+\def\tabl_nte_start_head[#1]#2\stopTABLEhead{\appendtoks\doTABLEsection[#1]{#2}\to\TBLhead}
+\def\tabl_nte_start_next[#1]#2\stopTABLEnext{\appendtoks\doTABLEsection[#1]{#2}\to\TBLnext}
+\def\tabl_nte_start_body[#1]#2\stopTABLEbody{\appendtoks\doTABLEsection[#1]{#2}\to\TBLbody}
+\def\tabl_nte_start_foot[#1]#2\stopTABLEfoot{\appendtoks\doTABLEsection[#1]{#2}\to\TBLfoot}
\protect \endinput
diff --git a/tex/context/base/tabl-tbl.lua b/tex/context/base/tabl-tbl.lua
index 21564a472..19548e7b3 100644
--- a/tex/context/base/tabl-tbl.lua
+++ b/tex/context/base/tabl-tbl.lua
@@ -15,7 +15,7 @@ local tonumber = tonumber
local gsub, rep, sub, find = string.gsub, string.rep, string.sub, string.find
local P, C, Cc, Ct, lpegmatch = lpeg.P, lpeg.C, lpeg.Cc, lpeg.Ct, lpeg.match
-local texsetcount = tex.setcount
+local settexcount = tex.setcount
local separator = P("|")
local nested = lpeg.patterns.nested
@@ -31,9 +31,9 @@ function commands.presettabulate(preamble)
end
local t = lpegmatch(pattern,preamble)
local m = #t - 2
- texsetcount("global","c_tabl_tabulate_nofcolumns", m/2)
- texsetcount("global","c_tabl_tabulate_has_rule_spec_first", t[1] == "" and 0 or 1)
- texsetcount("global","c_tabl_tabulate_has_rule_spec_last", t[m+1] == "" and 0 or 1)
+ settexcount("global","c_tabl_tabulate_nofcolumns", m/2)
+ settexcount("global","c_tabl_tabulate_has_rule_spec_first", t[1] == "" and 0 or 1)
+ settexcount("global","c_tabl_tabulate_has_rule_spec_last", t[m+1] == "" and 0 or 1)
for i=1,m,2 do
context.settabulateentry(t[i],t[i+1])
end
diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv
index fa2417712..2fa8c4805 100644
--- a/tex/context/base/tabl-tbl.mkiv
+++ b/tex/context/base/tabl-tbl.mkiv
@@ -48,7 +48,6 @@
% p p(dimen) of automatisch als alleen p
% w column width
% f font#1
-% A {alignmentoptions}
% B bold
% I italic
% S slanted
@@ -232,6 +231,7 @@
\unexpanded\def\tolerantTABLEbreaktrue {\settrue \c_tabl_tabulate_tolerant_break} % used in styles !
\unexpanded\def\handletabulatepbreakfalse{\setfalse\c_tabl_tabulate_handlepbreak } % depricated
+\installcorenamespace{tabulatealign}
\installcorenamespace{tabulatebox}
\installcorenamespace{tabulatesetup}
\installcorenamespace{tabulatehook}
@@ -296,6 +296,14 @@
% [|lg{.}|] => \NG 12.34 \NC
+\def\tabl_tabulate_charalign#1 % space delimited ! (will be redone in lua)
+ {\edef\alignmentclass{\the\c_tabl_tabulate_column}%
+ \edef\alignmentcharacter{\csname\??tabulatealign\the\c_tabl_tabulate_column\endcsname}%
+ \ifcase\c_tabl_tabulate_pass\or
+ \setfirstpasscharacteralign\checkalignment{#1}%
+ \fi % force hsize
+ \setsecondpasscharacteralign\checkalignment{#1}}
+
\def\tabl_tabulate_nobreak_inject_tracer
{\red % maybe use the fast color switcher here
\hrule\s!height.5\linewidth\s!depth.5\linewidth
@@ -416,8 +424,6 @@
\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
{\normalexpanded{\t_tabl_tabulate_preamble{\the\t_tabl_tabulate_preamble
\tabl_tabulate_check_local_vrule_thickness\constantdimenargument\d_tabl_tabulate_vrulethickness
@@ -433,7 +439,6 @@
\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
@@ -453,9 +458,6 @@
\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%
@@ -552,7 +554,6 @@
\installtabulatepreambleoption{d}{\t_tabl_tabulate_settings\expandafter{\the\t_tabl_tabulate_settings\fixedspaces}%
\tabl_tabulate_set_preamble}
\installtabulatepreambleoption{ }{\tabl_tabulate_set_preamble}
-\installtabulatepreambleoption{A}{\tabl_tabulate_set_alignment}
% We no longer deal with '~' here but map it onto 'd' instead. Of course
% we could prefix a key with \type {\meaning} instead, which works ok (and
@@ -618,22 +619,10 @@
{\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}%
- \fi}
-
\def\tabl_tabulate_set_align#1%
- {\global\settrue\c_tabl_auto_align_mode
- \setcharacteralign\c_tabl_tabulate_columns{#1}%
+ {\setvalue{\??tabulatealign\the\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}
@@ -654,11 +643,6 @@
\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
{\doifnextparenthesiselse
{\c_tabl_tabulate_modus\plusone
@@ -734,7 +718,6 @@
\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}
@@ -760,12 +743,10 @@
\t_tabl_tabulate_emath\emptytoks
\t_tabl_tabulate_font\emptytoks
\t_tabl_tabulate_settings\emptytoks
- \global\let\m_tabl_tabulate_alignment\empty
\global\let\m_tabl_tabulate_color\empty
\global\let\m_tabl_tabulate_text_color\empty
\global\let\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}%
@@ -775,7 +756,7 @@
\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
+ \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
@@ -852,7 +833,8 @@
\let\tabl_tabulate_hook\tabl_tabulate_hook_nop
-\def\tabl_tabulate_hook_yes{\csname\??tabulatehook\the\c_tabl_tabulate_column\endcsname}
+\def\tabl_tabulate_hook_yes {\csname\??tabulatehook \the\c_tabl_tabulate_column\endcsname}
+\def\tabl_tabulate_align_yes{\csname\??tabulatealign\the\c_tabl_tabulate_column\endcsname} % to be used
\def\tabl_tabulate_pheight_reset
{\global\c_tabl_tabulate_plines_min\plusone
@@ -1702,8 +1684,7 @@
\unexpanded\def\tabl_tabulate_RQ_first{\tabl_tabulate_column_equal \plusone}
\unexpanded\def\tabl_tabulate_HQ_first{\tabl_tabulate_column_equal \plustwo}
-%unexpanded\def\tabl_tabulate_NG_first{\NC\tabl_tabulate_charalign}
-\unexpanded\def\tabl_tabulate_NG_first{\NC}
+\unexpanded\def\tabl_tabulate_NG_first{\NC\tabl_tabulate_charalign}
\unexpanded\def\tabl_tabulate_NN_first{\NC\tabl_tabulate_digits} % new, undocumented, test first
\unexpanded\def\tabl_tabulate_ND_first{\NC\tabl_tabulate_digits} % same, for old times sake
@@ -1930,7 +1911,7 @@
\tabl_tabulate_nobreak_inject
\stoptabulatenoalign}
-\let\tabl_tabulate_BL_second_indeed\tabl_tabulate_TL_second_indeed
+\let\tabl_tabulate_BL_second\tabl_tabulate_TL_second
\def\tabl_tabulate_HL_second
{\csname
@@ -2023,8 +2004,6 @@
\let\tabl_tabulate_flush_collected \empty
\let\tabl_tabulate_flush_collected_indeed\empty
-\let\v_tabl_tabulate_align\!!zerocount
-
\def\tabl_tabulate_set_local_hsize
{\setlocalhsize
\hsize\localhsize}
diff --git a/tex/context/base/tabl-xtb.lua b/tex/context/base/tabl-xtb.lua
index 488ef5b78..3ffe8a219 100644
--- a/tex/context/base/tabl-xtb.lua
+++ b/tex/context/base/tabl-xtb.lua
@@ -27,12 +27,11 @@ this mechamism will be improved so that it can replace its older cousin.
local commands, context, tex, node = commands, context, tex, node
-local texgetcount = tex.getcount
+local texdimen = tex.dimen
+local texcount = tex.count
+local texbox = tex.box
local texsetcount = tex.setcount
-local texgetbox = tex.getbox
-local texgetdimen = tex.getdimen
local texsetdimen = tex.setdimen
-local texget = tex.get
local format = string.format
local concat = table.concat
@@ -172,11 +171,11 @@ function xtables.create(settings)
settings.leftmargindistance = tonumber(settings.leftmargindistance) or 0
settings.rightmargindistance = tonumber(settings.rightmargindistance) or 0
settings.options = settings_to_hash(settings.option)
- settings.textwidth = tonumber(settings.textwidth) or texget("hsize")
- settings.lineheight = tonumber(settings.lineheight) or texgetdimen("lineheight")
+ settings.textwidth = tonumber(settings.textwidth) or tex.hsize
+ settings.lineheight = tonumber(settings.lineheight) or texdimen.lineheight
settings.maxwidth = tonumber(settings.maxwidth) or settings.textwidth/8
-- if #stack > 0 then
- -- settings.textwidth = texget("hsize")
+ -- settings.textwidth = tex.hsize
-- end
data.criterium_v = 2 * data.settings.lineheight
data.criterium_h = .75 * data.settings.textwidth
@@ -187,10 +186,10 @@ function xtables.initialize_reflow_width(option)
local r = data.currentrow
local c = data.currentcolumn + 1
local drc = data.rows[r][c]
- drc.nx = texgetcount("c_tabl_x_nx")
- drc.ny = texgetcount("c_tabl_x_ny")
+ drc.nx = texcount.c_tabl_x_nx
+ drc.ny = texcount.c_tabl_x_ny
local distances = data.distances
- local distance = texgetdimen("d_tabl_x_distance")
+ local distance = texdimen.d_tabl_x_distance
if distance > distances[c] then
distances[c] = distance
end
@@ -215,7 +214,7 @@ function xtables.set_reflow_width()
while row[c].span do -- can also be previous row ones
c = c + 1
end
- local tb = texgetbox("b_tabl_x")
+ local tb = texbox.b_tabl_x
local drc = row[c]
--
drc.list = true -- we don't need to keep the content around as we're in trial mode (no: copy_node_list(tb))
@@ -233,7 +232,7 @@ function xtables.set_reflow_width()
depths[r] = depth
end
--
- local dimensionstate = texgetcount("frameddimensionstate")
+ local dimensionstate = texcount.frameddimensionstate
local fixedcolumns = data.fixedcolumns
local fixedrows = data.fixedrows
if dimensionstate == 1 then
@@ -295,19 +294,19 @@ function xtables.initialize_reflow_height()
for x=1,drc.nx-1 do
w = w + widths[c+x]
end
- texsetdimen("d_tabl_x_width",w)
+ texdimen.d_tabl_x_width = w
local dimensionstate = drc.dimensionstate or 0
if dimensionstate == 1 or dimensionstate == 3 then
-- width was fixed so height is known
- texsetcount("c_tabl_x_skip_mode",1)
+ texcount.c_tabl_x_skip_mode = 1
elseif dimensionstate == 2 then
-- height is enforced
- texsetcount("c_tabl_x_skip_mode",1)
+ texcount.c_tabl_x_skip_mode = 1
elseif data.autowidths[c] then
-- width has changed so we need to recalculate the height
- texsetcount("c_tabl_x_skip_mode",0)
+ texcount.c_tabl_x_skip_mode = 0
else
- texsetcount("c_tabl_x_skip_mode",1)
+ texcount.c_tabl_x_skip_mode = 1
end
end
@@ -316,10 +315,10 @@ function xtables.set_reflow_height()
local c = data.currentcolumn
local rows = data.rows
local row = rows[r]
- -- while row[c].span do -- we could adapt drc.nx instead
- -- c = c + 1
- -- end
- local tb = texgetbox("b_tabl_x")
+-- while row[c].span do -- we could adapt drc.nx instead
+-- c = c + 1
+-- end
+ local tb = texbox.b_tabl_x
local drc = row[c]
if data.fixedrows[r] == 0 then -- and drc.dimensionstate < 2
local heights, height = data.heights, tb.height
@@ -331,8 +330,8 @@ function xtables.set_reflow_height()
depths[r] = depth
end
end
- -- c = c + drc.nx - 1
- -- data.currentcolumn = c
+-- c = c + drc.nx - 1
+-- data.currentcolumn = c
end
function xtables.initialize_construct()
@@ -358,9 +357,9 @@ function xtables.initialize_construct()
h = h + heights[r+y]
d = d + depths[r+y]
end
- texsetdimen("d_tabl_x_width",w)
- texsetdimen("d_tabl_x_height",h + d)
- texsetdimen("d_tabl_x_depth",0)
+ texdimen.d_tabl_x_width = w
+ texdimen.d_tabl_x_height = h + d
+ texdimen.d_tabl_x_depth = 0
end
function xtables.set_construct()
@@ -368,14 +367,14 @@ function xtables.set_construct()
local c = data.currentcolumn
local rows = data.rows
local row = rows[r]
- -- while row[c].span do -- can also be previous row ones
- -- c = c + 1
- -- end
+-- while row[c].span do -- can also be previous row ones
+-- c = c + 1
+-- end
local drc = row[c]
-- this will change as soon as in luatex we can reset a box list without freeing
- drc.list = copy_node_list(texgetbox("b_tabl_x"))
- -- c = c + drc.nx - 1
- -- data.currentcolumn = c
+ drc.list = copy_node_list(texbox.b_tabl_x)
+-- c = c + drc.nx - 1
+-- data.currentcolumn = c
end
local function showwidths(where,widths,autowidths)
@@ -670,8 +669,8 @@ function xtables.construct()
end
local kern = new_kern(step)
if stop then
+ stop.prev = kern
stop.next = kern
- kern.prev = stop
else -- can be first spanning next row (ny=...)
start = kern
end
@@ -725,8 +724,6 @@ function xtables.construct()
end
end
--- todo: join as that is as efficient as fushing multiple
-
local function inject(row,copy,package)
local list = row[1]
if copy then
@@ -969,7 +966,7 @@ end
function xtables.next_row()
local r = data.currentrow + 1
- data.modes[r] = texgetcount("c_tabl_x_mode")
+ data.modes[r] = texcount.c_tabl_x_mode
data.currentrow = r
data.currentcolumn = 0
end
@@ -989,6 +986,3 @@ commands.x_table_init_construct = xtables.initialize_construct
commands.x_table_set_reflow_width = xtables.set_reflow_width
commands.x_table_set_reflow_height = xtables.set_reflow_height
commands.x_table_set_construct = xtables.set_construct
-
-commands.x_table_r = function() context(data.currentrow or 0) end
-commands.x_table_c = function() context(data.currentcolumn or 0) end
diff --git a/tex/context/base/tabl-xtb.mkvi b/tex/context/base/tabl-xtb.mkvi
index 556bec5ce..aba4e5027 100644
--- a/tex/context/base/tabl-xtb.mkvi
+++ b/tex/context/base/tabl-xtb.mkvi
@@ -94,10 +94,8 @@
\newdimen\d_tabl_x_final_width
\newcount\c_tabl_x_nesting
\newcount\c_tabl_x_skip_mode % 1 = skip
-\newdimen\d_tabl_x_textwidth
-\def\currentxtablerow {\ctxcommand{x_table_r()}}
-\def\currentxtablecolumn{\ctxcommand{x_table_c()}}
+\newdimen\d_tabl_x_textwidth
% \setupxtable[one][parent][a=b,c=d]
% \setupxtable[one] [a=b,c=d]
@@ -153,7 +151,6 @@
\let\stopxtable\relax
\def\tabl_x_default_buffer{x_table_\number\c_tabl_x_nesting}
-\let\tabl_x_current_buffer\empty
\unexpanded\def\tabl_x_start_table[#settings]% maybe two arguments: [tag][settings] | [tag] | [settings]
{\bgroup
diff --git a/tex/context/base/task-ini.lua b/tex/context/base/task-ini.lua
index 51aa550cb..0f477cb6e 100644
--- a/tex/context/base/task-ini.lua
+++ b/tex/context/base/task-ini.lua
@@ -12,10 +12,6 @@ if not modules then modules = { } end modules ['task-ini'] = {
-- we can disable more handlers and enable then when really used (*)
--
-- todo: two finalizers: real shipout (can be imposed page) and page shipout (individual page)
---
--- todo: consider moving the kernel kerning/ligaturing functions in the main font loop because
--- there we know if they are needed; doesn't save time but; if we overload unh* commands to
--- not apply the font handler, we can remove all checks for subtypes 255
local tasks = nodes.tasks
local appendaction = tasks.appendaction
@@ -27,7 +23,6 @@ appendaction("processors", "normalizers", "typesetters.characters.handler")
appendaction("processors", "normalizers", "fonts.collections.process") -- disabled
appendaction("processors", "normalizers", "fonts.checkers.missing") -- disabled
-appendaction("processors", "characters", "typesetters.characteralign.handler") -- disabled
appendaction("processors", "characters", "scripts.autofontfeature.handler")
appendaction("processors", "characters", "scripts.splitters.handler") -- disabled
appendaction("processors", "characters", "typesetters.cleaners.handler") -- disabled
@@ -37,10 +32,7 @@ appendaction("processors", "characters", "typesetters.breakpoints.handler")
appendaction("processors", "characters", "scripts.injectors.handler") -- disabled
appendaction("processors", "words", "builders.kernel.hyphenation") -- always on
-appendaction("processors", "words", "languages.words.check") -- disabled -- might move up, no disc check needed then
-
-appendaction("processors", "words", "typesetters.initials.handler") -- disabled -- might move up
-appendaction("processors", "words", "typesetters.firstlines.handler") -- disabled -- might move up
+appendaction("processors", "words", "languages.words.check") -- disabled
appendaction("processors", "fonts", "builders.paragraphs.solutions.splitters.split") -- experimental
appendaction("processors", "fonts", "nodes.handlers.characters") -- maybe todo
@@ -55,7 +47,7 @@ appendaction("processors", "lists", "typesetters.spacings.handler")
appendaction("processors", "lists", "typesetters.kerns.handler") -- disabled
appendaction("processors", "lists", "typesetters.digits.handler") -- disabled (after otf handling)
appendaction("processors", "lists", "typesetters.italics.handler") -- disabled (after otf/kern handling)
-------------("processors", "lists", "typesetters.initials.handler") -- disabled
+appendaction("processors", "lists", "typesetters.paragraphs.handler") -- disabled
appendaction("shipouts", "normalizers", "nodes.handlers.cleanuppage") -- disabled
appendaction("shipouts", "normalizers", "typesetters.alignments.handler")
@@ -79,8 +71,6 @@ appendaction("shipouts", "finishers", "attributes.viewerlayers.handler")
--maybe integrate relocate and families
-appendaction("math", "normalizers", "noads.handlers.showtree", nil, "nohead")
-
appendaction("math", "normalizers", "noads.handlers.unscript", nil, "nohead") -- always on (maybe disabled)
appendaction("math", "normalizers", "noads.handlers.variants", nil, "nohead") -- always on
appendaction("math", "normalizers", "noads.handlers.relocate", nil, "nohead") -- always on
@@ -93,11 +83,9 @@ appendaction("math", "normalizers", "noads.handlers.resize", nil, "noh
appendaction("math", "normalizers", "noads.handlers.check", nil, "nohead") -- always on
appendaction("math", "normalizers", "noads.handlers.tags", nil, "nohead") -- disabled
appendaction("math", "normalizers", "noads.handlers.italics", nil, "nohead") -- disabled
-appendaction("math", "normalizers", "noads.handlers.classes", nil, "nohead") -- disabled
appendaction("math", "builders", "builders.kernel.mlist_to_hlist") -- always on
------------("math", "builders", "noads.handlers.italics", nil, "nohead") -- disabled
-appendaction("math", "builders", "typesetters.directions.processmath") -- disabled (has to happen pretty late)
-- quite experimental (nodes.handlers.graphicvadjust might go away)
@@ -115,12 +103,11 @@ appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler")
-- experimental too
-appendaction("mvlbuilders", "normalizers","typesetters.checkers.handler")
+appendaction("mvlbuilders","normalizers","typesetters.checkers.handler")
appendaction("vboxbuilders","normalizers","typesetters.checkers.handler")
-- speedup: only kick in when used
-disableaction("processors", "typesetters.characteralign.handler")
disableaction("processors", "scripts.autofontfeature.handler")
disableaction("processors", "scripts.splitters.handler")
disableaction("processors", "scripts.injectors.handler") -- was enabled
@@ -133,12 +120,11 @@ disableaction("processors", "typesetters.digits.handler")
disableaction("processors", "typesetters.breakpoints.handler")
disableaction("processors", "typesetters.directions.handler")
disableaction("processors", "languages.words.check")
-disableaction("processors", "typesetters.initials.handler")
-disableaction("processors", "typesetters.firstlines.handler")
disableaction("processors", "typesetters.spacings.handler")
disableaction("processors", "typesetters.kerns.handler")
disableaction("processors", "typesetters.italics.handler")
disableaction("processors", "nodes.handlers.stripping")
+disableaction("processors", "typesetters.paragraphs.handler")
disableaction("shipouts", "typesetters.alignments.handler")
disableaction("shipouts", "nodes.rules.handler")
@@ -170,11 +156,8 @@ disableaction("finalizers", "builders.paragraphs.solutions.splitters.optimize")
disableaction("finalizers", "nodes.handlers.graphicvadjust") -- sort of obsolete
disableaction("finalizers", "builders.paragraphs.tag")
-disableaction("math", "noads.handlers.showtree")
disableaction("math", "noads.handlers.tags")
disableaction("math", "noads.handlers.italics")
-disableaction("math", "noads.handlers.classes")
-disableaction("math", "typesetters.directions.processmath")
disableaction("mvlbuilders", "typesetters.checkers.handler")
disableaction("vboxbuilders","typesetters.checkers.handler")
diff --git a/tex/context/base/toks-ini.lua b/tex/context/base/toks-ini.lua
index 0f0c016f8..ef4b5406b 100644
--- a/tex/context/base/toks-ini.lua
+++ b/tex/context/base/toks-ini.lua
@@ -5,7 +5,6 @@ if not modules then modules = { } end modules ['toks-ini'] = {
license = "see context related readme files"
}
-local context, commands = context, commands
local utfbyte, utfchar, utfvalues = utf.byte, utf.char, utf.values
local format, gsub = string.format, string.gsub
diff --git a/tex/context/base/trac-deb.lua b/tex/context/base/trac-deb.lua
index 4cc48c4a5..fe167c343 100644
--- a/tex/context/base/trac-deb.lua
+++ b/tex/context/base/trac-deb.lua
@@ -11,25 +11,22 @@ local lpeg, status = lpeg, status
local lpegmatch = lpeg.match
local format, concat, match = string.format, table.concat, string.match
local tonumber, tostring = tonumber, tostring
+local texdimen, textoks, texcount = tex.dimen, tex.toks, tex.count
-- maybe tracers -> tracers.tex (and tracers.lua for current debugger)
local report_system = logs.reporter("system","tex")
-tracers = tracers or { }
-local tracers = tracers
+tracers = tracers or { }
+local tracers = tracers
-tracers.lists = { }
-local lists = tracers.lists
+tracers.lists = { }
+local lists = tracers.lists
-tracers.strings = { }
-local strings = tracers.strings
+tracers.strings = { }
+local strings = tracers.strings
-local texgetdimen = tex.getdimen
-local texgettoks = tex.gettoks
-local texgetcount = tex.getcount
-
-strings.undefined = "undefined"
+strings.undefined = "undefined"
lists.scratch = {
0, 2, 4, 6, 8
@@ -74,16 +71,16 @@ function tracers.cs(csname)
end
function tracers.dimen(name)
- local d = texgetdimen(name)
+ local d = texdimen[name]
return d and number.topoints(d) or strings.undefined
end
function tracers.count(name)
- return texgetcount(name) or strings.undefined
+ return texcount[name] or strings.undefined
end
function tracers.toks(name,limit)
- local t = texgettoks(name)
+ local t = textoks[name]
return t and string.limit(t,tonumber(limit) or 40) or strings.undefined
end
diff --git a/tex/context/base/trac-inf.lua b/tex/context/base/trac-inf.lua
index 79cbdba3f..eefc15a6f 100644
--- a/tex/context/base/trac-inf.lua
+++ b/tex/context/base/trac-inf.lua
@@ -11,24 +11,20 @@ if not modules then modules = { } end modules ['trac-inf'] = {
-- get warnings about assignments. This is more efficient than using rawset
-- and rawget.
-local type, tonumber, select = type, tonumber, select
+local type, tonumber = type, tonumber
local format, lower = string.format, string.lower
local concat = table.concat
local clock = os.gettimeofday or os.clock -- should go in environment
-local setmetatableindex = table.setmetatableindex
-local serialize = table.serialize
-local formatters = string.formatters
+statistics = statistics or { }
+local statistics = statistics
-statistics = statistics or { }
-local statistics = statistics
-
-statistics.enable = true
-statistics.threshold = 0.01
+statistics.enable = true
+statistics.threshold = 0.01
local statusinfo, n, registered, timers = { }, 0, { }, { }
-setmetatableindex(timers,function(t,k)
+table.setmetatableindex(timers,function(t,k)
local v = { timing = 0, loadtime = 0 }
t[k] = v
return v
@@ -182,19 +178,6 @@ function statistics.timed(action)
report("total runtime: %s",elapsedtime("run"))
end
--- goodie
-
-function statistics.tracefunction(base,tag,...)
- for i=1,select("#",...) do
- local name = select(i,...)
- local stat = { }
- local func = base[name]
- setmetatableindex(stat,function(t,k) t[k] = 0 return 0 end)
- base[name] = function(n,k,v) stat[k] = stat[k] + 1 return func(n,k,v) end
- statistics.register(formatters["%s.%s"](tag,name),function() return serialize(stat,"calls") end)
- end
-end
-
-- where, not really the best spot for this:
commands = commands or { }
diff --git a/tex/context/base/trac-jus.lua b/tex/context/base/trac-jus.lua
index 38220a752..9d99f059d 100644
--- a/tex/context/base/trac-jus.lua
+++ b/tex/context/base/trac-jus.lua
@@ -15,16 +15,19 @@ local a_alignstate = attributes.private("alignstate")
local a_justification = attributes.private("justification")
local tracers = nodes.tracers
-local tracedrule = tracers.rule
+local setcolor = tracers.colors.set
+local settransparency = tracers.transparencies.set
local new_rule = nodes.pool.rule
-local new_hlist = nodes.pool.hlist
local new_glue = nodes.pool.glue
local new_kern = nodes.pool.kern
+local concat_nodes = nodes.concat
+local hpack_nodes = node.hpack
+local copy_node = node.copy
local get_list_dimensions = node.dimensions
local hlist_code = nodes.nodecodes.hlist
-local texsetattribute = tex.setattribute
+local tex_set_attribute = tex.setattribute
local unsetvalue = attributes.unsetvalue
local min_threshold = 0
@@ -33,14 +36,14 @@ local max_threshold = 0
local function set(n)
nodes.tasks.enableaction("mvlbuilders", "typesetters.checkers.handler")
nodes.tasks.enableaction("vboxbuilders","typesetters.checkers.handler")
- texsetattribute(a_justification,n or 1)
+ tex_set_attribute(a_justification,n or 1)
function typesetters.checkers.set(n)
- texsetattribute(a_justification,n or 1)
+ tex_set_attribute(a_justification,n or 1)
end
end
local function reset()
- texsetattribute(a_justification,unsetvalue)
+ tex_set_attribute(a_justification,unsetvalue)
end
checkers.set = set
@@ -71,22 +74,58 @@ function checkers.handler(head)
if naturalwidth == 0 or delta == 0 then
-- special box
elseif delta >= max_threshold then
- local rule = tracedrule(delta,naturalheight,naturaldepth,list.glue_set == 1 and "trace:dr"or "trace:db")
- current.list = list .. new_hlist(rule)
+ local rule = new_rule(delta,naturalheight,naturaldepth)
+ list = hpack_nodes(list,width,"exactly")
+ if list.glue_set == 1 then
+ setcolor(rule,"trace:dr")
+ settransparency(rule,"trace:dr")
+ else
+ setcolor(rule,"trace:db")
+ settransparency(rule,"trace:db")
+ end
+ rule = hpack_nodes(rule)
+ rule.width = 0
+ rule.height = 0
+ rule.depth = 0
+ current.list = concat_nodes { list, rule }
+ -- current.list = concat_nodes { list, new_kern(-naturalwidth+width), rule }
elseif delta <= min_threshold then
local alignstate = list[a_alignstate]
if alignstate == 1 then
- local rule = tracedrule(-delta,naturalheight,naturaldepth,"trace:dc")
- current.list = new_hlist(rule) .. list
+ local rule = new_rule(-delta,naturalheight,naturaldepth)
+ setcolor(rule,"trace:dc")
+ settransparency(rule,"trace:dc")
+ rule = hpack_nodes(rule)
+ rule.height = 0
+ rule.depth = 0
+ rule.width = 0
+ current.list = nodes.concat { rule, list }
elseif alignstate == 2 then
- local rule = tracedrule(-delta/2,naturalheight,naturaldepth,"trace:dy")
- current.list = new_hlist(rule^1) .. list .. new_kern(delta/2) .. new_hlist(rule)
+ local rule = new_rule(-delta/2,naturalheight,naturaldepth)
+ setcolor(rule,"trace:dy")
+ settransparency(rule,"trace:dy")
+ rule = hpack_nodes(rule)
+ rule.width = 0
+ rule.height = 0
+ rule.depth = 0
+ current.list = concat_nodes { copy_node(rule), list, new_kern(delta/2), rule }
elseif alignstate == 3 then
- local rule = tracedrule(-delta,naturalheight,naturaldepth,"trace:dm")
- current.list = list .. new_kern(delta) .. new_hlist(rule)
+ local rule = new_rule(-delta,naturalheight,naturaldepth)
+ setcolor(rule,"trace:dm")
+ settransparency(rule,"trace:dm")
+ rule = hpack_nodes(rule)
+ rule.height = 0
+ rule.depth = 0
+ current.list = concat_nodes { list, new_kern(delta), rule }
else
- local rule = tracedrule(-delta,naturalheight,naturaldepth,"trace:dg")
- current.list = list .. new_kern(delta) .. new_hlist(rule)
+ local rule = new_rule(-delta,naturalheight,naturaldepth)
+ setcolor(rule,"trace:dg")
+ settransparency(rule,"trace:dg")
+ rule = hpack_nodes(rule)
+ rule.height = 0
+ rule.depth = 0
+ rule.width = 0
+ current.list = concat_nodes { list, new_kern(delta), rule }
end
end
end
diff --git a/tex/context/base/trac-lmx.lua b/tex/context/base/trac-lmx.lua
index 41d930536..18c7f6020 100644
--- a/tex/context/base/trac-lmx.lua
+++ b/tex/context/base/trac-lmx.lua
@@ -430,7 +430,7 @@ local optionalspaces = whitespace^0
local dquote = P('"')
-local begincomment = P("")
local beginembedxml = P("")
@@ -505,8 +505,7 @@ local resolvecss = ((beginembedcss * P("lmx-resolve") * optionalspaces) / ""
* ((Carg(1) * C(argumentcss)) / getdefinition)
* gobbledendcss
------ pattern_1 = Cs((commentxml + includexml + includecss + P(1))^0) -- get rid of xml comments asap .. not good enough: embedded css and script is in