diff options
Diffstat (limited to 'tex')
52 files changed, 917 insertions, 497 deletions
diff --git a/tex/context/base/anch-pgr.mkiv b/tex/context/base/anch-pgr.mkiv index ad1194b53..ba566f970 100644 --- a/tex/context/base/anch-pgr.mkiv +++ b/tex/context/base/anch-pgr.mkiv @@ -373,7 +373,7 @@ \let\dohandleMPpositiongraphic\docleanMPpositiongraphic \to \everycleanpositionaction -%D Graphics that span two positions. +%D Graphics that span two positions (beware, does not cross pages). \def\setMPpositiongraphicrange {\doquadruplegroupempty\dosetMPpositiongraphicrange} @@ -1340,6 +1340,9 @@ \newcount\noftabpositions \newtoks \posXCtoks +\def\dotablebpos{\bpos} +\def\dotableepos{\epos} + \def\tbPOSprefix {tbp:\number\noftabpositions:} @@ -1352,8 +1355,8 @@ \def\dodododoGSC[#1:#2]% {\remappositionframed{#2}{\tbPOSprefix#1}% - \bpos{\tbPOSprefix#1}% - \doglobal\appendtoks\@EA\epos\@EA{\tbPOSprefix#1}\to\posXCtoks} + \dotablebpos{\tbPOSprefix#1}% + \doglobal\appendtoks\@EA\dotableepos\@EA{\tbPOSprefix#1}\to\posXCtoks} \def\dododoGSC[#1:#2:#3]% {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC} @@ -1364,7 +1367,7 @@ \def\dodododoGFC[#1:#2:#3]% {\remappositionframed{#2}{\tbPOSprefix#1}% - \bpos{\tbPOSprefix#1}} + \dotablebpos{\tbPOSprefix#1}} \def\dododoGFC[#1]% {\def\docommand##1{\dodododoGFC[##1:##1]}% @@ -1374,7 +1377,7 @@ {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC} \def\dododododoGTC[#1:#2]% - {\epos{\tbPOSprefix#1}} + {\dotableepos{\tbPOSprefix#1}} \def\dodododoGTC[#1]% {\def\docommand##1{\dododododoGTC[##1:##1]}% @@ -1436,6 +1439,39 @@ \global\advance\noftabpositions\plusone \to \everytabulate +% We need to handle paragraphs as well. + +\let\doflushtabulateepos\relax + +\def\dotabulatebpos + {\bpos} + +\def\dotabulateepos#1% + {\ifvoid\tablebox\tabulatecolumn + \epos{#1}% + \glet\doflushtabulateepos\relax + \else + \gdef\doflushtabulateepos{\epos{#1}}% + \fi} + +\def\splitofftabulatebox + {\dontcomplain + \global\setbox\tabulatebox % % % global ? % % % + \vsplit\tablebox\tabulatecolumn to \lineheight + \setbox\tabulatebox\normalvbox + {\unvbox\tabulatebox}% + \setbox\tabulatebox\hbox to \wd\tabulatebox + {\hss\dotabulatehook{\box\tabulatebox}\hss}% + \ht\tabulatebox\strutht + \dp\tabulatebox\strutdp + \box\tabulatebox + \doflushtabulateepos} + +\appendtoks + \let\dotablebpos\dotabulatebpos + \let\dotableepos\dotabulateepos +\to \everytabulate + %D In order to prevent potential clashes with abbreviations, %D postpone the mapping. diff --git a/tex/context/base/attr-ini.mkiv b/tex/context/base/attr-ini.mkiv index 3997d546b..43cb66d35 100644 --- a/tex/context/base/attr-ini.mkiv +++ b/tex/context/base/attr-ini.mkiv @@ -26,6 +26,7 @@ \definesystemattribute[colormodel][global] % no reset \definesystemattribute[color] \definesystemattribute[transparency] +\definesystemattribute[background] \definesystemattribute[overprint] \definesystemattribute[negative] \definesystemattribute[effect] diff --git a/tex/context/base/back-pdf.lua b/tex/context/base/back-pdf.lua index dd0fb504b..7f04ced5f 100644 --- a/tex/context/base/back-pdf.lua +++ b/tex/context/base/back-pdf.lua @@ -13,8 +13,9 @@ parenthesis; they are needed because otherwise we would pass more than one argument to <l n='tex'/>.</p> --ldx]]-- -local type, next = type, next +local type, next, tostring = type, next, tostring local char, byte, format, gsub = string.char, string.byte, string.format, string.gsub +local concat = table.concat local utfcharacters, utfvalues = string.utfcharacters, string.utfvalues local texsprint, texwrite = tex.sprint, tex.write diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv index b7de1051f..fcfc53091 100644 --- a/tex/context/base/back-pdf.mkiv +++ b/tex/context/base/back-pdf.mkiv @@ -279,10 +279,10 @@ \def\setsubmitoutputformat#1% {\doifinsetelse{#1}{FDF,fdf} - {\chardef\submitoutputformat2} + {\chardef\submitoutputformat\plustwo} {\doifinsetelse{#1}{XML,xml} - {\chardef\submitoutputformat3} - {\chardef\submitoutputformat1}}% + {\chardef\submitoutputformat\plusthree} + {\chardef\submitoutputformat\plusone}}% \relax} %D Handy to have this available asap: diff --git a/tex/context/base/buff-ini.lua b/tex/context/base/buff-ini.lua index fb61ba01d..4be320f76 100644 --- a/tex/context/base/buff-ini.lua +++ b/tex/context/base/buff-ini.lua @@ -174,13 +174,25 @@ function buffers.typeline(str,n,m,line) return n, line end -function buffers.save(name) +function buffers.save(name,list,encapsulate) if not name or name == "" then name = tex.jobname end - local b, f = data[name], tex.jobname .. "-" .. name .. ".tmp" - b = (b and type(b) == "table" and table.join(b,"\n")) or b or "" - io.savedata(f,b) + if list then + -- ok + else + list = name + name = tex.jobname .. "-" .. name .. ".tmp" + end + local content = buffers.collect(list) + if content == "" then + content = "empty buffer" + end + if encapsulate then + io.savedata(name, "\\starttext\n"..content.."\n\\stoptext\n") + else + io.savedata(name, content) + end end local printer = (lpeg.linebyline/texprint)^0 @@ -214,7 +226,7 @@ end buffers.content = content function buffers.collect(names,separator) -- no print - -- maybe we shoul always store a buffer as table so + -- maybe we should always store a buffer as table so -- that we can pass if directly local t = { } if type(names) == "table" then diff --git a/tex/context/base/colo-ini.lua b/tex/context/base/colo-ini.lua index c615aad7f..4a188eba8 100644 --- a/tex/context/base/colo-ini.lua +++ b/tex/context/base/colo-ini.lua @@ -31,7 +31,8 @@ local registrations = backends.registrations local a_color = attributes.private('color') local a_transparency = attributes.private('transparency') -local a_colorspace = attributes.private('colorspace') +local a_colorspace = attributes.private('colormodel') +local a_background = attributes.private('background') local a_l_c_template = "\\setevalue{(ca:%s)}{%s}" .. "\\setevalue{(cs:%s)}{\\dosetattribute{color}{%s}}" diff --git a/tex/context/base/colo-ini.mkiv b/tex/context/base/colo-ini.mkiv index e4365c5e0..197a69ba6 100644 --- a/tex/context/base/colo-ini.mkiv +++ b/tex/context/base/colo-ini.mkiv @@ -869,6 +869,8 @@ \setfalse\collectcolorsinlist \def\collectcolorinlist#1{\doglobal\addtocommalist{#1}\colorlist} +\def\doregistercolor#1#2{\ctxlua{ctx.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}} + \def\dodefinecolor[#1][#2]% {\ifconditional\collectcolorsinlist\collectcolorinlist{#1}\fi \ctxlua{ctx.defineprocesscolor("#1","#2",false,\iffreezecolors true\else false\fi)}% diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index effac4b79..a453c1160 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.06.07 13:11} +\newcontextversion{2009.06.10 11:22} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 7473b39b3..18a999574 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -65,6 +65,8 @@ \loadcorefile{core-var.tex} +\loadmarkfile{lpdf-ini} + \loadmarkfile{back-ini} \loadmarkfile{back-pdf} diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 2889cf196..d94c0cc91 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.06.07 13:11} +\edef\contextversion{2009.06.10 11:22} %D For those who want to use this: diff --git a/tex/context/base/core-spa.mkiv b/tex/context/base/core-spa.mkiv index 9f2c47bf1..1a4e2825d 100644 --- a/tex/context/base/core-spa.mkiv +++ b/tex/context/base/core-spa.mkiv @@ -1049,7 +1049,7 @@ \ctxlua{tex.sprint(tex.ctxcatcodes,"\string\\unexpanded\string\\def\string\\\string\n{\string\\ }")} -\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\space} +\unexpanded\def\nonbreakablespace{\penalty\plustenthousand\mathortext\ \space} % no space in math \letcatcodecommand \ctxcatcodes `\~ \nonbreakablespace % overloaded later diff --git a/tex/context/base/font-ctx.lua b/tex/context/base/font-ctx.lua index e87b21165..2f51c5229 100644 --- a/tex/context/base/font-ctx.lua +++ b/tex/context/base/font-ctx.lua @@ -282,17 +282,20 @@ local specification -- local get_specification = define.get_specification +-- we can make helper macros which saves parsing (but normaly not +-- that many calls, e.g. in mk a couple of 100 and in metafun 3500) + function define.command_1(str) statistics.starttiming(fonts) local fullname, size = splitpattern:match(str) local lookup, name, sub, method, detail = get_specification(fullname) if not name then logs.report("define font","strange definition '%s'",str) - texsprint(ctxcatcodes,"\\glet\\somefontname\\defaultfontfile") + texsprint(ctxcatcodes,"\\fcglet\\somefontname\\defaultfontfile") elseif name == "unknown" then - texsprint(ctxcatcodes,"\\glet\\somefontname\\defaultfontfile") + texsprint(ctxcatcodes,"\\fcglet\\somefontname\\defaultfontfile") else - texsprint(ctxcatcodes,format("\\xdef\\somefontname{%s}",name)) + texsprint(ctxcatcodes,format("\\fcxdef\\somefontname{%s}",name)) end -- we can also use a count for the size if size and size ~= "" then @@ -316,6 +319,8 @@ function define.command_1(str) specification = define.makespecification(str,lookup,name,sub,method,detail,size) end +local n = 0 + function define.command_2(global,cs,str,size,classfeatures,fontfeatures,classfallbacks,fontfallbacks,mathsize,textsize) -- name is now resolved and size is scaled cf sa/mo local lookup, name, sub, method, detail = get_specification(str or "") diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua index e56b263a1..cb4721e7c 100644 --- a/tex/context/base/font-def.lua +++ b/tex/context/base/font-def.lua @@ -538,6 +538,7 @@ function define.read(specification,size,id) -- id can be optional, name can alre fontdata.encodingname or "unicode", fontdata.fullname or "?", file.basename(fontdata.filename or "?")) + end statistics.stoptiming(fonts) return fontdata diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv index 4d0d92fc5..5ce6248ea 100644 --- a/tex/context/base/font-ini.mkiv +++ b/tex/context/base/font-ini.mkiv @@ -467,42 +467,42 @@ % \let\mathsizesuffix\empty -\chardef\currentmathsize\zerocount +\let\currentmathsize\empty -\def\mathsizesuffix{\ifcase\currentmathsize\or\mathtextsuffix\or\mathscriptscriptsuffix\or\mathscriptsuffix\fi} +\def\mathsizesuffix{\ifcase0\currentmathsize\or\mathtextsuffix\or\mathscriptscriptsuffix\or\mathscriptsuffix\fi} \def\dodosetmathfamily#1#2% - {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse - \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else - \ifcsname\fontclass \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue - \csname\fontclass \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + {\ifcsname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse + \csname\fontclass \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue + \csname\fontclass \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else \dodosetmathfamilyx#1#2% \fi\fi #1#2\font} \def\dodosetmathfamilyx#1#2% - {\ifcsname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse - \csname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else - \ifcsname\defaultfontclass\fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue - \csname\defaultfontclass\fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + {\ifcsname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse + \csname\defaultfontclass\fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue + \csname\defaultfontclass\fontbody\c!mm\fontfamily \currentmathsize\endcsname \else \dodosetmathfamilyxx#1#2% \fi\fi} \def\dodosetmathfamilyxx#1#2% - {\ifcsname \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \autofontsizefalse - \csname \fontbody\c!mm\fontfamily\fontsize\the\currentmathsize\endcsname \else - \ifcsname \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \autofontsizetrue - \csname \fontbody\c!mm\fontfamily \the\currentmathsize\endcsname \else + {\ifcsname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \autofontsizefalse + \csname \fontbody\c!mm\fontfamily\fontsize\currentmathsize\endcsname \else + \ifcsname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \autofontsizetrue + \csname \fontbody\c!mm\fontfamily \currentmathsize\endcsname \else \nullfont \autofontsizetrue \fi\fi} \def\dosetmathfamily#1#2% {\let\savedfontbody\fontbody % op hoger plan \let\fontfamily#2% - \let\currentmathsize\plusthree\let\fontbody\scriptscriptface\dodosetmathfamily\scriptscriptfont#1% - \let\currentmathsize\plustwo \let\fontbody\scriptface \dodosetmathfamily\scriptfont #1% - \let\currentmathsize\plusone \let\fontbody\textface \dodosetmathfamily\textfont #1% - \let\currentmathsize\zerocount + \let\currentmathsize\!!plusthree\let\fontbody\scriptscriptface\dodosetmathfamily\scriptscriptfont#1% + \let\currentmathsize\!!plustwo \let\fontbody\scriptface \dodosetmathfamily\scriptfont #1% + \let\currentmathsize\!!plusone \let\fontbody\textface \dodosetmathfamily\textfont #1% + \let\currentmathsize\empty \let\fontbody\savedfontbody \autofontsizefalse} @@ -675,7 +675,7 @@ "\@@fontfeatures", "\@@fontclassfallbacks", "\@@fontfallbacks", - \number\currentmathsize, + 0\currentmathsize, \number\dimexpr\textface\relax )}% \edef\somefontspec{at \somefontsize}% we need the resolved designsize (for fallbacks) @@ -903,21 +903,25 @@ % hm, was wrong, class/global reversed +\let\fcglobal\global +\let\fcxdef \xdef +\let\fcglet \glet + \def\nonodefinefontsynonymnop {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\undefined \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\undefined} \def\nonodefinefontsynonymyes - {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined} + {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\undefined + \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\undefined} \def\dodododefinefontsynonymnop {\@EA\let\csname\??ff\@@fontname\s!features \endcsname\@@ff@@features \@EA\let\csname\??ff\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} \def\dodododefinefontsynonymyes - {\global\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features - \global\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} + {\fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!features \endcsname\@@ff@@features + \fcglobal\@EA\let\csname\??ff\fontclass\@@fontname\s!fallbacks\endcsname\@@ff@@fallbacks} \let\definefontfile\definefontsynonym % dedicated to Taco Hoekwater @@ -935,52 +939,6 @@ \fi \fi} -% \def\truefontname#1% -% {\@EA\dotruefontname#1*\empty*\relax} -% -% \def\dotruefontname#1*#2#3*#4\relax -% {\ifcsname\??ff\fontclass#1\endcsname -% \ifx#2\empty -% \@EA\truefontname\csname\??ff\fontclass#1\endcsname -% \else -% \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname*#2#3% -% \fi -% \else\ifcsname\??ff#1\endcsname -% \ifx#2\empty -% \@EA\truefontname\csname\??ff#1\endcsname -% \else -% \@EA\redotruefontname\csname\??ff#1\endcsname*#2#3% -% \fi -% \else -% #1\ifx#2\empty\else*#2#3\fi -% \fi\fi} -% -% \def\redotruefontname#1% -% {\@EA\dodotruefontname#1*\relax} -% -% \def\dodotruefontname#1*#2\relax -% {\ifcsname\??ff\fontclass#1\endcsname -% \@EA\redotruefontname\csname\??ff\fontclass#1\endcsname -% \else\ifcsname\??ff#1\endcsname -% \@EA\redotruefontname\csname\??ff#1\endcsname -% \else -% #1% -% \fi\fi} -% -% \def\expandfontsynonym#1#2% #2 := onelevelexpansion(#1) -% {\ifcsname\??ff\fontclass#2\endcsname -% \expandafter\def\expandafter#1\expandafter{\csname\??ff\fontclass#2\endcsname}% -% \fi} -% -% \def\doifelsefontsynonym#1% -% {\ifcsname\??ff\fontclass#1\endcsname -% \expandafter\firstoftwoarguments -% \else -% \expandafter\secondoftwoarguments -% \fi} - -% maybe we need to stick in one branch - \def\truefontname#1% {\@EA\dotruefontname#1*\empty*\relax} @@ -1090,17 +1048,6 @@ \def\definefont {\dotripleempty\dodefinefont} -% \def\dodefinefont[#1][#2][#3]% [name][spec][1.6 | line=10pt | setup_id] -% {\doifinstringelse{ }{#2} -% {\ifthirdargument -% \unexpanded\setvalue{#1}{\redodefinefont{#1}{#2}{#3}}% -% \else -% \unexpanded\setvalue{#1}{\dododefinefont{#1}{#2}}% -% \fi} -% {\definefont[#1][#2 sa *][#3]}} - -% we moved the unspecified size check to lua - \def\dodefinefont[#1][#2][#3]% [name][spec][1.6 | line=10pt | setup_id] {\ifthirdargument \unexpanded\setvalue{#1}{\redodefinefont{#1}{#2}{#3}}% @@ -1129,8 +1076,11 @@ \let\lastfontidentifier\empty -\def\rawfontidentifier{**\lastfontidentifier\fontsize**} -\def\newfontidentifier{*\fontclass\lastfontidentifier\fontsize*} +\def\rawfontidentifier{**\lastfontidentifier\fontsize\currentmathsize**} +\def\newfontidentifier{*\fontclass\lastfontidentifier\fontsize\currentmathsize*} + +\let\oldrawfontidentifier\rawfontidentifier +\let\oldnewfontidentifier\newfontidentifier % best we can add the style as well because otherwise we get math encoding mixups % @@ -1149,7 +1099,8 @@ \csname\rawfontidentifier\endcsname \autofontsizefalse \setfontcharacteristics - \the\everyfontswitch} + \the\everyfontswitch + \let\rawfontidentifier\oldrawfontidentifier} \def\xxdododefinefont#1#2#3#4% \autofontsizetrue is set by calling routine {\edef\lastfontidentifier{#3}% @@ -1165,7 +1116,8 @@ \ifskipfontcharacteristics \else \setfontcharacteristics \the\everyfontswitch - \fi} + \fi + \let\newfontidentifier\oldnewfontidentifier} %D \macros %D {mapfontsize} @@ -1614,8 +1566,8 @@ \def\dodefinebodyfontyesxx#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \global\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined - \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}} + \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#5*\endcsname\undefined + \normalprotected\@EA\fcxdef\csname\fontclass#2#1#3#4#5\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#5}{\normalunexpanded{#6}}}} \def\dodefinebodyfontnopmm#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] @@ -1628,12 +1580,12 @@ \def\dodefinebodyfontyesmm#1#2[#3#4#5=#6]% style body def {\ifcsname#1#3#4#5\endcsname\else\checkbodyfont{#1}{#3#4}{#5}\fi% not \definefontsize[#5] - \global\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined - \global\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined - \global\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined - \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% - \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% - \normalprotected\@EA\xdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}} + \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#51*\endcsname\undefined + \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#52*\endcsname\undefined + \fcglobal\@EA\let\csname*\fontclass#2#1#3#4#53*\endcsname\undefined + \normalprotected\@EA\fcxdef\csname\fontclass#2#1#3#4#51\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#51}{\normalunexpanded{#6}}}% + \normalprotected\@EA\fcxdef\csname\fontclass#2#1#3#4#52\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#52}{\normalunexpanded{#6}}}% + \normalprotected\@EA\fcxdef\csname\fontclass#2#1#3#4#53\endcsname{\noexpand\xxdododefinefont{\number\relativefontsize}{#2}{#2#1#3#4#53}{\normalunexpanded{#6}}}} \def\checkbodyfont#1% tests for ttsl mmbf {\def\c!!mm{#1}% diff --git a/tex/context/base/grph-fig.mkiv b/tex/context/base/grph-fig.mkiv index c7f990af2..61f78f09e 100644 --- a/tex/context/base/grph-fig.mkiv +++ b/tex/context/base/grph-fig.mkiv @@ -447,30 +447,29 @@ % \appendtoks \setbuffer[typeset-b]\endbuffer\to \everystarttext % \appendtoks \setbuffer[typeset-a]\endbuffer\to \everystarttext +\newcount\noftypesetbuffers + \def\typesetbuffer {\dodoubleempty\dotypesetbuffer} -\newcounter\noftypesetbuffers % all loaded at the end - -\defineexternalfigure - [typeset] - [\c!background=\v!color, - \c!backgroundcolor=\s!white] - \def\dotypesetbuffer[#1][#2]% beware: this will mix up the mp graphics + {\ifsecondargument + \dodotypesetbuffer[#1][#2]% + \else\iffirstargument + \doifassignmentelse{#1} + {\dodotypesetbuffer[\jobname][#1]}% + {\dodotypesetbuffer[#1][]}% + \else + \dodotypesetbuffer[\jobname][] + \fi\fi} + +\def\dodotypesetbuffer[#1][#2]% beware: this will mix up the mp graphics {\bgroup - \def\TEXbufferfile##1{\bufferprefix##1.tex}% - \expanded{\setbuffer[typeset]% - \def\noexpand\bufferprefix{\ifprotectbuffers\jobname-\fi typeset-}}% - \starttext - \getbuffer[b,#1,a]% - \stoptext - \endbuffer - \doglobal\increment\noftypesetbuffers - % batch is needed - \executesystemcommand{texmfstart texexec --batch --pdf --result=\bufferprefix typeset-\noftypesetbuffers\space \bufferprefix typeset.tex}% - %\externalfigure[\bufferprefix typeset-\noftypesetbuffers.pdf][\c!object=\v!no,#2]% - \externalfigure[\bufferprefix typeset-\noftypesetbuffers.pdf][#2]% + \global\advance\noftypesetbuffers\plusone + \edef\bufferfilename{\jobname-buffer-\the\noftypesetbuffers}% + \ctxlua{buffers.save("\bufferfilename.tmp","#1",true)}% + \executesystemcommand{context \bufferfilename.tmp}% + \externalfigure[\bufferfilename.pdf][#2]% \egroup} % for me only (manuals and such) @@ -519,7 +518,7 @@ \c!xmax=] \useexternalfigure - [buffer] [\jobname] [\c!type=\v!buffer,\c!object=\v!no] + [buffer] [\jobname.buffer] [\c!object=\v!no] \protect \endinput diff --git a/tex/context/base/grph-inc.lua b/tex/context/base/grph-inc.lua index d132b8b16..5b3bff36c 100644 --- a/tex/context/base/grph-inc.lua +++ b/tex/context/base/grph-inc.lua @@ -33,7 +33,7 @@ The TeX-Lua mix is suboptimal. This has to do with the fact that we cannot run TeX code from within Lua. Some more functionality will move to Lua. ]]-- -local texsprint, format, lower = tex.sprint, string.format, string.lower +local texsprint, format, lower, find, match = tex.sprint, string.format, string.lower, string.find, string.match local ctxcatcodes = tex.ctxcatcodes @@ -383,14 +383,14 @@ local function locate(request) -- name, format, cache local format = figures.suffixes[askedformat] if not format then for _, pattern in ipairs(figures.patterns) do - if askedformat:find(pattern[1]) then + if find(askedformat,pattern[1]) then format = pattern[2] break end end end if format then - local foundname = figures.exists(askedname,askedformat) + local foundname = figures.exists(askedname,format) -- not askedformat if foundname then return register(askedname, { askedname = askedname, @@ -694,8 +694,30 @@ figures.includers.mov = figures.includers.nongeneric -- -- -- mps -- -- -- +local function internal(askedname) + local spec, mprun, mpnum = match(lower(askedname),"mprun(:?)(.-)%.(%d+)") + if spec == ":" then + return mprun, mpnum + else + return "", mpnum + end +end + +function figures.existers.mps(askedname) + local mprun, mpnum = internal(askedname) + if mpnum then + return askedname + else + return figures.existers.generic(askedname) + end +end function figures.checkers.mps(data) - return figures.checkers.nongeneric(data,format("\\docheckfiguremps{%s}",data.used.fullname)) + local mprun, mpnum = internal(data.used.fullname) + if mpnum then + return figures.checkers.nongeneric(data,format("\\docheckfiguremprun{%s}{%s}",mprun,mpnum)) + else + return figures.checkers.nongeneric(data,format("\\docheckfiguremps{%s}",data.used.fullname)) + end end figures.includers.mps = figures.includers.nongeneric diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index e55e9698a..96ea2d74a 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -220,9 +220,10 @@ \def\doprocessmpslikefigure#1% retrofit into mkii {\global\setbox\foundexternalfigure\vbox{\convertMPtoPDF{#1}11}} -\def\docheckfigurebuffer#1{\doprocesstexlikefigure{\getbuffer[#1]}} -\def\docheckfiguretex #1{\doprocesstexlikefigure{\input#1\relax}} -\def\docheckfiguremps #1{\doprocessmpslikefigure{#1}} +\def\docheckfigurebuffer #1{\doprocesstexlikefigure{\getbuffer[#1]}} +\def\docheckfiguretex #1{\doprocesstexlikefigure{\input#1\relax}} +\def\docheckfiguremps #1{\doprocessmpslikefigure{#1}} +\def\docheckfiguremprun #1#2{\doprocesstexlikefigure{\useMPrun{#1}{#2}}} \def\doscalefigure {\global\setbox\foundexternalfigure\vbox{\doscalebox\??ef{\dowithfigure{\box\foundexternalfigure}}}} diff --git a/tex/context/base/l-string.lua b/tex/context/base/l-string.lua index ab7d314e4..f46d6df24 100644 --- a/tex/context/base/l-string.lua +++ b/tex/context/base/l-string.lua @@ -226,3 +226,8 @@ function string.tabtospace(str,tab) return str end +function string:compactlong() -- strips newlines and leading spaces + self = gsub(self,"[\n\r]+ *","") + self = gsub(self,"^ *","") + return self +end diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua new file mode 100644 index 000000000..4676ad7c2 --- /dev/null +++ b/tex/context/base/lpdf-ini.lua @@ -0,0 +1,207 @@ +if not modules then modules = { } end modules ['back-pdf'] = { + version = 1.001, + comment = "companion to lpdf-ini.tex", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local setmetatable, getmetatable, type, next, tostring = setmetatable, getmetatable, type, next, tostring +local char, byte, format, gsub = string.char, string.byte, string.format, string.gsub +local concat = table.concat +local utfvalues = string.utfvalues + +lpdf = lpdf or { } + +local function tosixteen(str) + if not str or str == "" then + return "()" + else + local r = { "<feff" } + for b in utfvalues(str) do + if b < 0x10000 then + r[#r+1] = format("%04x",b) + else + r[#r+1] = format("%04x%04x",b/1024+0xD800,b%1024+0xDC00) + end + end + r[#r+1] = ">" + return concat(r) + end +end + +local function merge_t(a,b) + local t = { } + for k,v in next, a do t[k] = v end + for k,v in next, b do t[k] = v end + return setmetatable(t,getmetatable(a)) +end + +local tostring_a, tostring_d, tosting_n, tostring_s, tostring_c + +tostring_d = function(t) + if not next(t) then + return "<< >>" + else + local r = { "<<" } + for k, v in next, t do + local tv = type(v) + if tv == "string" then + r[#r+1] = format("/%s %s",k,tosixteen(v)) + elseif tv == "table" then + local mv = getmetatable(v) + if mv and mv.__lpdftype then + r[#r+1] = format("/%s %s",k,tostring(v)) + elseif v[1] then + r[#r+1] = format("/%s %s",k,tostring_a(v)) + else + r[#r+1] = format("/%s %s",k,tostring_d(v)) + end + else + r[#r+1] = format("/%s %s",k,tostring(v)) + end + end + r[#r+1] = ">>" + return concat(r, " ") + end +end + +tostring_a = function(t) + if #t == 0 then + return "[ ]" + else + local r = { "[" } + for k, v in next, t do + local tv = type(v) + if tv == "string" then + r[#r+1] = tosixteen(v) + elseif tv == "table" then + local mv = getmetatable(v) + if mv and mv.__lpdftype then + r[#r+1] = tostring(v) + elseif v[1] then + r[#r+1] = tostring_a(v) + else + r[#r+1] = tostring_d(v) + end + else + r[#r+1] = tostring(v) + end + end + r[#r+1] = "]" + return concat(r, " ") + end +end + +tostring_n = function(t) + return tostring(t[1]) -- tostring not needed +end + +tostring_s = function(t) + return tosixteen(t[1]) +end + +tostring_c = function(t) + return t[1] +end + +local mt_d = { __lpdftype = "dictionary", __tostring = tostring_d } +local mt_a = { __lpdftype = "array", __tostring = tostring_a } +local mt_s = { __lpdftype = "string", __tostring = tostring_s } +local mt_n = { __lpdftype = "number", __tostring = tostring_n } +local mt_c = { __lpdftype = "constant", __tostring = tostring_c } + +local mt_z = { __lpdftype = "null", __tostring = function(s) return "null" end } +local mt_t = { __lpdftype = "true", __tostring = function(s) return "true" end } +local mt_f = { __lpdftype = "false", __tostring = function(s) return "false" end } + +function lpdf.dictionary(t) + return setmetatable(t or { },mt_d) +end + +function lpdf.array(t) + return setmetatable(t or { },mt_a) +end + +local cache = { } -- can be weak + +function lpdf.string(str,default) + str = str or default or "" + local c = cache[str] + if not c then + c = setmetatable({ str },mt_s) + cache[str] = c + end + return c +end + +local cache = { } -- can be weak + +function lpdf.number(n,default) -- 0-10 + n = n or default + local c = cache[n] + if not c then + c = setmetatable({ n },mt_n) + -- cache[n] = c -- too many numbers + end + return c +end + +for i=-1,9 do cache[i] = lpdf.number(i) end + +local cache = { } -- can be weak + +function lpdf.constant(str,default) + str = str or default or "" + local c = cache[str] + if not c then + c = setmetatable({ "/" .. str },mt_c) + cache[str] = c + end + return c +end + +local p_null = { } setmetatable(p_null, mt_z) +local p_true = { } setmetatable(p_true, mt_t) +local p_false = { } setmetatable(p_false,mt_f) + +function lpdf.null () return p_null end + +function lpdf.boolean(b,default) + if (type(b) == boolean and b) or default then + return p_true + else + return p_false + end +end + +--~ local d = lpdf.dictionary() +--~ local e = lpdf.dictionary { ["e"] = "abc" } +--~ local f = lpdf.dictionary { ["f"] = "ABC" } +--~ local a = lpdf.array() + +--~ d["test"] = lpdf.string ("test") +--~ d["more"] = "more" +--~ d["bool"] = true +--~ d["numb"] = 1234 +--~ d["oeps"] = lpdf.dictionary { ["hans"] = "ton" } +--~ d["whow"] = lpdf.array { lpdf.string("ton") } + +--~ a[#a+1] = lpdf.string("xxx") +--~ a[#a+1] = lpdf.string("yyy") + +--~ d.what = a + +--~ print(d) + +--~ local d = lpdf.dictionary() +--~ d["abcd"] = { 1, 2, 3, "test" } +--~ print(d) + +--~ local d = lpdf.array() +--~ d[#d+1] = { 1, 2, 3, "test" } +--~ print(d) + +--~ local d = lpdf.array() +--~ d[#d+1] = { a=1, b=2, c=3, d="test" } +--~ print(d) diff --git a/tex/context/base/lpdf-ini.mkiv b/tex/context/base/lpdf-ini.mkiv new file mode 100644 index 000000000..23a81cfec --- /dev/null +++ b/tex/context/base/lpdf-ini.mkiv @@ -0,0 +1,18 @@ +%D \module +%D [ file=lpdf-ini, +%D version=2009.04.15, +%D title=\CONTEXT\ Backend Macros, +%D subtitle=PDF, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright=\PRAGMA] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Backend Macros / PDF} + +\registerctxluafile{lpdf-ini}{1.001} + +\endinput diff --git a/tex/context/base/luat-lib.mkiv b/tex/context/base/luat-lib.mkiv index ec781f3cf..1905ee67d 100644 --- a/tex/context/base/luat-lib.mkiv +++ b/tex/context/base/luat-lib.mkiv @@ -53,7 +53,7 @@ \long\def\message #1{\normalmessage{<m t='message'>#1</m>}} \else \let\writebanner\writestring - \let\writestatus\normalwritestatus + %\let\writestatus\normalwritestatus \let\message \normalmessage \fi \stopruntimeluacode diff --git a/tex/context/base/math-ini.mkiv b/tex/context/base/math-ini.mkiv index b87096661..cb5a63440 100644 --- a/tex/context/base/math-ini.mkiv +++ b/tex/context/base/math-ini.mkiv @@ -329,28 +329,53 @@ %D The result is as expected: the first line typesets ok, while the second %D one triggers an error message. -\bgroup +\newtoks\everydonknuthmode +\newtoks\everynonknuthmode + +\def\nonknuthmode{\the\everynonknuthmode\let\nonknuthmode\relax} +\def\donknuthmode{\the\everydonknuthmode} - \ifx\normalsuber\undefined \def\normalsuber{_} \fi - \ifx\normalsuper\undefined \def\normalsuper{^} \fi +\ifdefined\normalsuber\else \def\normalsuber{_} \fi +\ifdefined\normalsuper\else \def\normalsuper{^} \fi + +\bgroup \catcode`_=\active \catcode`^=\active - \gdef\nonknuthmode - {\appendtoks\let_\normalsuber\let^\normalsuper\to\everymathematics - \mathcode`_="8000 - \mathcode`^="8000 - \catcode`_=\@@other - \catcode`^=\@@other - \let\nonknuthmode\relax} - - \gdef\donknuthmode - {\catcode`_=\@@subscript - \catcode`^=\@@superscript} + \global \everynonknuthmode {\appendtoks + \let_\normalsuber + \let^\normalsuper + \to \everymathematics} \egroup +\appendtoks + \mathcode`_="8000 + \mathcode`^="8000 + \catcode`_=\@@other + \catcode`^=\@@other +\to \everynonknuthmode + +\appendtoks + \catcode`_=\@@subscript + \catcode`^=\@@superscript +\to \everydonknuthmode + +\appendtoks + \startextendcatcodetable\ctxcatcodes + \catcode`_=\@@other + \catcode`^=\@@other + \stopextendcatcodetable +\to \everynonknuthmode + +\appendtoks + \startextendcatcodetable\ctxcatcodes + \catcode`_=\@@subscript + \catcode`^=\@@superscript + \stopextendcatcodetable +\to \everydonknuthmode + %D Needed for unicode: \def\nulloperator{\mathortext{\mathop{\null}}{\null}} diff --git a/tex/context/base/meta-ini.mkiv b/tex/context/base/meta-ini.mkiv index fd501d0ca..0e0adc54f 100644 --- a/tex/context/base/meta-ini.mkiv +++ b/tex/context/base/meta-ini.mkiv @@ -169,6 +169,7 @@ \defineMPinstance[metafun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[extrafun][\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] +\defineMPinstance[mprun] [\s!format=metafun,\s!extensions=\v!yes,\s!initializations=\v!yes] \defineMPinstance[metapost][\s!format=mpost] \defineMPinstance[nofun] [\s!format=mpost] @@ -183,6 +184,8 @@ \newconditional \METAFUNinitialized +\def\MPaskedfigure{false} + % maybe we need to force black, i.e. fake nodes \long\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig @@ -195,7 +198,8 @@ \setbox\MPgraphicbox\hbox\bgroup \ctxlua{metapost.graphic("\currentMPformat", "\currentMPformat", \@EA\!!bs\the\MPinitializations;\theMPrandomseed;#1;\!!es, % code - \@EA\@EA\@EA\!!bs\@EA\the\@EA\MPextensions\@EA;\the\MPuserinclusions;\!!es % optional preamble + \@EA\@EA\@EA\!!bs\@EA\the\@EA\MPextensions\@EA;\the\MPuserinclusions;\!!es, % optional preamble + \MPaskedfigure )}% \global\settrue\METAFUNinitialized \global\MPextensions\emptytoks @@ -224,7 +228,8 @@ \setbox\MPgraphicbox\hbox\bgroup \normalexpanded{\noexpand\ctxlua{metapost.graphic("\currentMPgraphicinstance", "\currentMPgraphicformat", \!!bs\ifconditional\includeMPinitializations\the\MPinitializations;\fi\theMPrandomseed;#1;\!!es, - \!!bs\ifconditional\includeMPextensions\the\MPextensions;\the\MPuserinclusions;\fi\the\MPinstancetoks;\!!es + \!!bs\ifconditional\includeMPextensions\the\MPextensions;\the\MPuserinclusions;\fi\the\MPinstancetoks;\!!es, + \MPaskedfigure )}}% \egroup \global\MPinstancetoks\emptytoks @@ -281,24 +286,24 @@ \def\getMPdrawing{\dosinglegroupempty\dogetMPdrawing} -\def\nodogetMPdrawing#1% - {\ifMPdrawingdone - \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% - \fi} - -\def\dostartMPcode - {\iffirstargument - \expandafter\dodogetMPdrawing - \else - \expandafter\nodogetMPdrawing - \fi} - -\def\dodogetMPdrawing#1% - {\ifMPdrawingdone - \beginMPgraphicgroup{#1::\s!dummy}% name does not matter - \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% - \endMPgraphicgroup - \fi} +% \def\nodogetMPdrawing#1% +% {\ifMPdrawingdone +% \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% +% \fi} +% +% \def\dostartMPcode +% {\iffirstargument +% \expandafter\dodogetMPdrawing +% \else +% \expandafter\nodogetMPdrawing +% \fi} +% +% \def\dodogetMPdrawing#1% +% {\ifMPdrawingdone +% \beginMPgraphicgroup{#1::\s!dummy}% name does not matter +% \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% +% \endMPgraphicgroup +% \fi} \def\startMPdrawing {\dosingleempty\dostartMPdrawing} @@ -877,6 +882,48 @@ \let\stopMPcode\relax +% a bit nasty (also needed for compatibility: + +% \startMPrun input mp-www.mp ; \stopMPrun +% \externalfigure[mprun.3][width=10cm,height=8cm] + +% \startMPrun{mprun} input mp-www.mp ; \stopMPrun % instance +% \externalfigure[mprun.4][width=10cm,height=8cm] + +\let\MPruninstance\defaultMPgraphicinstance + +% \def\useMPrun#1#2% name n +% {\begingroup +% \def\MPaskedfigure{#2}% +% \doifelsenothing{#1} +% {\useMPgraphic{\MPruninstance::mprun}}% +% {\useMPgraphic{\MPruninstance::#1}}% +% \endgroup} +% \def\startMPrun +% {\dosinglegroupempty\dostartMPrun} +% \long\def\dostartMPrun#1#2\stopMPrun +% {\edef\MPruninstance{\iffirstargument#1\else\defaultMPgraphicinstance\fi}% +% \startuseMPgraphic{mprun}#2\stopuseMPgraphic} + + +\def\useMPrun#1#2% name n + {\begingroup + \def\MPaskedfigure{#2}% + \doifelsenothing{#1} + {\useMPgraphic{mprun}}% + {\useMPgraphic{#1}}% + \endgroup} + +\def\startMPrun + {\dosinglegroupempty\dostartMPrun} + +\long\def\dostartMPrun#1#2\stopMPrun + {\iffirstargument + \startuseMPgraphic{#1}#2\stopuseMPgraphic + \else + \startuseMPgraphic{mprun}#1\stopuseMPgraphic + \fi} + % for old time sake \def\dostartMPgraphic @@ -1012,7 +1059,8 @@ \to \everyMPgraphic \appendtoks % before color - \normalexpanded{\noexpand\definecolor[currentcolor][\currentcolorname]}% + %\normalexpanded{\noexpand\definecolor[currentcolor][\currentcolorname]}% + \doregistercolor{currentcolor}\currentcolorname \to \everyMPgraphic % \color[green]{abc \startMPcode diff --git a/tex/context/base/mlib-ctx.lua b/tex/context/base/mlib-ctx.lua index 8109003ca..4d4e25a3d 100644 --- a/tex/context/base/mlib-ctx.lua +++ b/tex/context/base/mlib-ctx.lua @@ -14,9 +14,9 @@ local sprint = tex.sprint metapost = metapost or {} metapost.defaultformat = "metafun" -function metapost.graphic(instance,mpsformat,str,preamble) +function metapost.graphic(instance,mpsformat,str,preamble,askedfig) local mpx = metapost.format(instance,mpsformat or metapost.defaultformat) - metapost.graphic_base_pass(mpx,str,preamble) + metapost.graphic_base_pass(mpx,str,preamble,askedfig) end function metapost.filterclippath(result) diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index b2997dab9..8dfa5e552 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -41,17 +41,17 @@ local function getobjects(result,figure,f) end end -function metapost.convert(result, trialrun, flusher, multipass) +function metapost.convert(result, trialrun, flusher, multipass, askedfig) if trialrun then metapost.multipass = false - metapost.parse(result, flusher) + metapost.parse(result, askedfig) if multipass and not metapost.multipass and metapost.optimize then - metapost.flush(result, flusher) -- saves a run + metapost.flush(result, flusher, askedfig) -- saves a run else return false end else - metapost.flush(result, flusher) + metapost.flush(result, flusher, askedfig) end return true -- done end @@ -224,7 +224,7 @@ metapost.specials = metapost.specials or { } -- the flusher is pdf based, if another backend is used, we need to overload the -- flusher; this is beta code, the organization will change -function metapost.flush(result,flusher) -- pdf flusher, table en dan concat is sneller, 1 literal +function metapost.flush(result,flusher,askedfig) -- pdf flusher, table en dan concat is sneller, 1 literal if result then local figures = result.fig if figures then @@ -234,216 +234,223 @@ function metapost.flush(result,flusher) -- pdf flusher, table en dan concat is s for f=1, #figures do local figure = figures[f] local objects = getobjects(result,figure,f) - local fignum = tonumber((figure:filename()):match("([%d]+)$") or figure:charcode() or 0) - 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] -- faster than unpack -metapost.llx = llx -metapost.lly = lly -metapost.urx = urx -metapost.ury = ury - if urx < llx then - -- invalid - flusher.startfigure(fignum,0,0,0,0,"invalid",figure) - flusher.stopfigure() - else - flusher.startfigure(fignum,llx,lly,urx,ury,"begin",figure) - t[#t+1] = "q" - if objects then -t[#t+1] = metapost.colorinitializer() - -- once we have multiple prescripts we can do more tricky things like - -- text and special colors at the same time - for o=1,#objects do - local object = objects[o] - local objecttype = object.type - if objecttype == "start_bounds" or objecttype == "stop_bounds" then - -- skip - elseif objecttype == "start_clip" then - t[#t+1] = "q" - flushnormalpath(object.path,t,false) - t[#t+1] = "W n" - elseif objecttype == "stop_clip" then - t[#t+1] = "Q" - miterlimit, linecap, linejoin, dashed = -1, -1, -1, false - elseif objecttype == "special" then - metapost.specials.register(object.prescript) - elseif objecttype == "text" then - t[#t+1] = "q" - local ot = object.transform -- 3,4,5,6,1,2 - t[#t+1] = format("%f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) -- TH: format("%f %f m %f %f %f %f 0 0 cm",unpack(ot)) - flusher.flushfigure(t) -- flush accumulated literals - t = { } - flusher.textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) - t[#t+1] = "Q" - else - -- alternatively we can pass on the stack, could be a helper - -- can be optimized with locals - local currentobject = { -- not needed when no extensions - type = object.type, - miterlimit = object.miterlimit, - linejoin = object.linejoin, - linecap = object.linecap, - color = object.color, - dash = object.dash, - path = object.path, - htap = object.htap, - pen = object.pen, - prescript = object.prescript, - postscript = object.postscript, - } ---~ print(table.serialize(currentobject)) - -- - local before, inbetween, after = nil, nil, nil - -- - local cs, cr = currentobject.color, nil - -- todo document why ... - if cs and colorhandler and #cs > 0 and round(cs[1]*10000) == 123 then -- test in function - currentobject, cr = colorhandler(cs,currentobject,t,colorconverter) - objecttype = currentobject.type - end - -- - local prescript = currentobject.prescript - if prescript and prescript ~= "" then - -- move test to function - local special = metapost.specials[prescript] - if special then - currentobject, before, inbetween, after = special(currentobject.postscript,currentobject,t,flusher) + local fignum = figure:charcode() or 0 + if not askedfig 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] -- faster than unpack + metapost.llx = llx + metapost.lly = lly + metapost.urx = urx + metapost.ury = ury + if urx < llx then + -- invalid + flusher.startfigure(fignum,0,0,0,0,"invalid",figure) + flusher.stopfigure() + else + flusher.startfigure(fignum,llx,lly,urx,ury,"begin",figure) + t[#t+1] = "q" + if objects then + t[#t+1] = metapost.colorinitializer() + -- once we have multiple prescripts we can do more tricky things like + -- text and special colors at the same time + for o=1,#objects do + local object = objects[o] + local objecttype = object.type + if objecttype == "start_bounds" or objecttype == "stop_bounds" then + -- skip + elseif objecttype == "start_clip" then + t[#t+1] = "q" + flushnormalpath(object.path,t,false) + t[#t+1] = "W n" + elseif objecttype == "stop_clip" then + t[#t+1] = "Q" + miterlimit, linecap, linejoin, dashed = -1, -1, -1, false + elseif objecttype == "special" then + metapost.specials.register(object.prescript) + elseif objecttype == "text" then + t[#t+1] = "q" + local ot = object.transform -- 3,4,5,6,1,2 + t[#t+1] = format("%f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2]) -- TH: format("%f %f m %f %f %f %f 0 0 cm",unpack(ot)) + flusher.flushfigure(t) -- flush accumulated literals + t = { } + flusher.textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth) + t[#t+1] = "Q" + else + -- alternatively we can pass on the stack, could be a helper + -- can be optimized with locals + local currentobject = { -- not needed when no extensions + type = object.type, + miterlimit = object.miterlimit, + linejoin = object.linejoin, + linecap = object.linecap, + color = object.color, + dash = object.dash, + path = object.path, + htap = object.htap, + pen = object.pen, + prescript = object.prescript, + postscript = object.postscript, + } + --~ print(table.serialize(currentobject)) + -- + local before, inbetween, after = nil, nil, nil + -- + local cs, cr = currentobject.color, nil + -- todo document why ... + if cs and colorhandler and #cs > 0 and round(cs[1]*10000) == 123 then -- test in function + currentobject, cr = colorhandler(cs,currentobject,t,colorconverter) objecttype = currentobject.type end - end - -- - cs = currentobject.color - if cs and #cs > 0 then - t[#t+1], cr = colorconverter(cs) - end - -- - if before then currentobject, t = before() end - local ml = currentobject.miterlimit - if ml and ml ~= miterlimit then - miterlimit = ml - t[#t+1] = format("%f M",ml) - end - local lj = currentobject.linejoin - if lj and lj ~= linejoin then - linejoin = lj - t[#t+1] = format("%i j",lj) - end - local lc = currentobject.linecap - if lc and lc ~= linecap then - linecap = lc - t[#t+1] = format("%i J",lc) - end - local dl = currentobject.dash - if dl then - local d = format("[%s] %i d",concat(dl.dashes or {}," "),dl.offset) - if d ~= dashed then - dashed = d - t[#t+1] = dashed + -- + local prescript = currentobject.prescript + if prescript and prescript ~= "" then + -- move test to function + local special = metapost.specials[prescript] + if special then + currentobject, before, inbetween, after = special(currentobject.postscript,currentobject,t,flusher) + objecttype = currentobject.type + end end - elseif dashed then - t[#t+1] = "[] 0 d" - dashed = false - end - if inbetween then currentobject, t = inbetween() end - local path = currentobject.path - local transformed, penwidth = false, 1 - local open = path and path[1].left_type and path[#path].right_type -- at this moment only "end_point" - local pen = currentobject.pen - if pen then - if pen.type == 'elliptical' then - transformed, penwidth = pen_characteristics(object) -- boolean, value - t[#t+1] = format("%f w",penwidth) -- todo: only if changed - if objecttype == 'fill' then - objecttype = 'both' + -- + cs = currentobject.color + if cs and #cs > 0 then + t[#t+1], cr = colorconverter(cs) + end + -- + if before then currentobject, t = before() end + local ml = currentobject.miterlimit + if ml and ml ~= miterlimit then + miterlimit = ml + t[#t+1] = format("%f M",ml) + end + local lj = currentobject.linejoin + if lj and lj ~= linejoin then + linejoin = lj + t[#t+1] = format("%i j",lj) + end + local lc = currentobject.linecap + if lc and lc ~= linecap then + linecap = lc + t[#t+1] = format("%i J",lc) + end + local dl = currentobject.dash + if dl then + local d = format("[%s] %i d",concat(dl.dashes or {}," "),dl.offset) + if d ~= dashed then + dashed = d + t[#t+1] = dashed end - else -- calculated by mplib itself - objecttype = 'fill' - end - end - if transformed then - t[#t+1] = "q" - end - if path then - if transformed then - flushconcatpath(path,t,open) - else - flushnormalpath(path,t,open) + elseif dashed then + t[#t+1] = "[] 0 d" + dashed = false end - if objecttype == "fill" then - t[#t+1] = "h f" - elseif objecttype == "outline" then - t[#t+1] = (open and "S") or "h S" - elseif objecttype == "both" then - t[#t+1] = "h B" + if inbetween then currentobject, t = inbetween() end + local path = currentobject.path + local transformed, penwidth = false, 1 + local open = path and path[1].left_type and path[#path].right_type -- at this moment only "end_point" + local pen = currentobject.pen + if pen then + if pen.type == 'elliptical' then + transformed, penwidth = pen_characteristics(object) -- boolean, value + t[#t+1] = format("%f w",penwidth) -- todo: only if changed + if objecttype == 'fill' then + objecttype = 'both' + end + else -- calculated by mplib itself + objecttype = 'fill' + end end - end - if transformed then - t[#t+1] = "Q" - end - local path = currentobject.htap - if path then if transformed then t[#t+1] = "q" end - if transformed then - flushconcatpath(path,t,open) - else - flushnormalpath(path,t,open) - end - if objecttype == "fill" then - t[#t+1] = "h f" - elseif objecttype == "outline" then - t[#t+1] = (open and "S") or "h S" - elseif objecttype == "both" then - t[#t+1] = "h B" + if path then + if transformed then + flushconcatpath(path,t,open) + else + flushnormalpath(path,t,open) + end + if objecttype == "fill" then + t[#t+1] = "h f" + elseif objecttype == "outline" then + t[#t+1] = (open and "S") or "h S" + elseif objecttype == "both" then + t[#t+1] = "h B" + end end if transformed then t[#t+1] = "Q" end + local path = currentobject.htap + if path then + if transformed then + t[#t+1] = "q" + end + if transformed then + flushconcatpath(path,t,open) + else + flushnormalpath(path,t,open) + end + if objecttype == "fill" then + t[#t+1] = "h f" + elseif objecttype == "outline" then + t[#t+1] = (open and "S") or "h S" + elseif objecttype == "both" then + t[#t+1] = "h B" + end + if transformed then + t[#t+1] = "Q" + end + end + if cr then + t[#t+1] = cr + end + if after then currentobject, t = after() end end - if cr then - t[#t+1] = cr - end - if after then currentobject, t = after() end - end - end + end + end + t[#t+1] = "Q" + flusher.flushfigure(t) + flusher.stopfigure("end") end - t[#t+1] = "Q" - flusher.flushfigure(t) - flusher.stopfigure("end") + break end end end end end -function metapost.parse(result) +function metapost.parse(result,askedfig) if result then local figures = result.fig if figures then for f=1, #figures do local figure = figures[f] -local bbox = figure:boundingbox() -local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4] -- faster than unpack -metapost.llx = llx -metapost.lly = lly -metapost.urx = urx -metapost.ury = ury - local objects = getobjects(result,figure,f) - if objects then - for o=1,#objects do - local object = objects[o] - if object.type == "outline" then - local prescript = object.prescript - if prescript then - local special = metapost.specials[prescript] - if special then - special(object.postscript,object) + local fignum = figure:charcode() or 0 + if not askedfig or (askedfig == fignum) then + local bbox = figure:boundingbox() + local llx, lly, urx, ury = bbox[1], bbox[2], bbox[3], bbox[4] -- faster than unpack + metapost.llx = llx + metapost.lly = lly + metapost.urx = urx + metapost.ury = ury + local objects = getobjects(result,figure,f) + if objects then + for o=1,#objects do + local object = objects[o] + if object.type == "outline" then + local prescript = object.prescript + if prescript then + local special = metapost.specials[prescript] + if special then + special(object.postscript,object) + end end - end - end + end + end end + break end end end diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua index eaaf1fc17..04a9ba230 100644 --- a/tex/context/base/mlib-pps.lua +++ b/tex/context/base/mlib-pps.lua @@ -39,7 +39,6 @@ local colordata = { {}, {}, {}, {}, {} } --~ => transparent spot : r=123 g= 5 b=hash --~ => rest : r=123 g=n>10 b=whatever - local nooutercolor = "0 g 0 G" local nooutertransparency = "/Tr0 gs" local outercolormode = 0 @@ -722,7 +721,8 @@ metapost.intermediate.needed = false metapost.method = 1 -- 1:dumb 2:clever -function metapost.graphic_base_pass(mpsformat,str,preamble) +function metapost.graphic_base_pass(mpsformat,str,preamble,askedfig) + local nofig = (askedfig and "") or false local done_1, done_2, forced_1, forced_2 str, done_1, forced_1 = metapost.check_texts(str) if preamble then @@ -738,12 +738,12 @@ function metapost.graphic_base_pass(mpsformat,str,preamble) -- first true means: trialrun, second true means: avoid extra run if no multipass local flushed = metapost.process(mpsformat, { preamble, - "beginfig(1); ", + nofig or "beginfig(1); ", "if unknown _trial_run_ : boolean _trial_run_ fi ; _trial_run_ := true ;", str, - "endfig ;" + nofig or "endfig ;" -- }, true, nil, true ) - }, true, nil, not (forced_1 or forced_2), false) + }, true, nil, not (forced_1 or forced_2), false, askedfig) if metapost.intermediate.needed then for _, action in pairs(metapost.intermediate.actions) do action() @@ -752,30 +752,31 @@ function metapost.graphic_base_pass(mpsformat,str,preamble) 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 - sprint(ctxcatcodes,"\\ctxlua{metapost.graphic_extra_pass()}") + sprint(ctxcatcodes,format("\\ctxlua{metapost.graphic_extra_pass(%s)}",askedfig or "false")) end else metapost.process(mpsformat, { preamble or "", - "beginfig(1); ", + nofig or "beginfig(1); ", "_trial_run_ := false ;", str, - "endfig ;" - }, false, nil, false, false ) + nofig or "endfig ;" + }, false, nil, false, false, askedfig ) end -- here we could free the textext boxes metapost.free_boxes() end -function metapost.graphic_extra_pass() +function metapost.graphic_extra_pass(askedfig) + local nofig = (askedfig and "") or false metapost.textext_current = metapost.first_box metapost.process(current_format, { - "beginfig(1); ", + nofig or "beginfig(1); ", "_trial_run_ := false ;", concat(metapost.text_texts_data()," ;\n"), current_graphic, - "endfig ;" - }, false, nil, false, true ) + nofig or "endfig ;" + }, false, nil, false, true, askedfig ) end function metapost.getclippath(data) diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 1644feb4a..d22e0d742 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -116,6 +116,7 @@ function metapost.load(name) ini_version = false, mem_name = file.replacesuffix(name,"mem"), find_file = finder, +--~ job_name = "mplib", } ) ) local result @@ -213,6 +214,7 @@ function metapost.format(instance,name) name = name or instance local mpx = mpxformats[instance] if not mpx then + commands.writestatus("mplib","initializing instance '%s' using format '%s'",instance,name) mpx = metapost.checkformat(name) mpxformats[instance] = mpx end @@ -240,7 +242,7 @@ end local mp_inp, mp_log, mp_tag = { }, { }, 0 -function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass) +function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass, askedfig) local converted, result = false, {} if type(mpx) == "string" then mpx = metapost.format(mpx) -- goody @@ -282,7 +284,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass) end end if result.fig then - converted = metapost.convert(result, trialrun, flusher, multipass) + converted = metapost.convert(result, trialrun, flusher, multipass, askedfig) end end else @@ -313,7 +315,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass) metapost.report("mp info: %s",result.term or "no-term") end if result.fig then - converted = metapost.convert(result, trialrun, flusher, multipass) + converted = metapost.convert(result, trialrun, flusher, multipass, askedfig) end end end @@ -327,7 +329,7 @@ function metapost.process(mpx, data, trialrun, flusher, multipass, isextrapass) return converted, result end -function metapost.convert(result, trialrun, multipass) +function metapost.convert() metapost.report('mp warning: no converter set') end diff --git a/tex/context/base/node-inj.lua b/tex/context/base/node-inj.lua index 6ba21b39d..2e8b5ae81 100644 --- a/tex/context/base/node-inj.lua +++ b/tex/context/base/node-inj.lua @@ -168,7 +168,7 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -function nodes.inject_kerns(head,tail,keep) +function nodes.inject_kerns(head,tail,where,keep) if trace_injections then nodes.trace_injection(head) end @@ -176,10 +176,10 @@ function nodes.inject_kerns(head,tail,keep) if has_marks or has_cursives then -- in the future variant we will not copy items but refs to tables local done, ky, rl, valid, cx, wx = false, { }, { }, { }, { }, { } - for n in traverse_id(glyph,head) do - if n.subtype < 256 then - valid[#valid+1] = n - if has_kerns then -- move outside loop + if has_kerns then -- move outside loop + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n local k = has_attribute(n,kernpair) if k then local kk = kerns[k] @@ -197,6 +197,12 @@ function nodes.inject_kerns(head,tail,keep) end end end + else + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n + end + end end if #valid > 0 then -- we can assume done == true because we have cursives and marks @@ -215,6 +221,7 @@ function nodes.inject_kerns(head,tail,keep) n = valid[i] if n.font ~= nf then nf = n.font +--~ print(n.font,nf,fontdata[nf]) tm = fontdata[nf].marks -- maybe flush maxt = 0 diff --git a/tex/context/base/node-pro.lua b/tex/context/base/node-pro.lua index 575941fe5..a14ccc1a1 100644 --- a/tex/context/base/node-pro.lua +++ b/tex/context/base/node-pro.lua @@ -74,7 +74,7 @@ function nodes.processors.pre_linebreak_filter(head,groupcode) -- todo: tail if found then if trace_callbacks then local before = nodes.count(head,true) - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) local after = nodes.count(head,true) if done then tracer("pre_linebreak","changed",head,groupcode,before,after,true) @@ -83,7 +83,7 @@ function nodes.processors.pre_linebreak_filter(head,groupcode) -- todo: tail end return (done and head) or true else - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) return (done and head) or true end elseif trace_callbacks then @@ -98,7 +98,7 @@ function nodes.processors.hpack_filter(head,groupcode) -- todo: tail if found then if trace_callbacks then local before = nodes.count(head,true) - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) local after = nodes.count(head,true) if done then tracer("hpack","changed",head,groupcode,before,after,true) @@ -107,7 +107,7 @@ function nodes.processors.hpack_filter(head,groupcode) -- todo: tail end return (done and head) or true else - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) return (done and head) or true end elseif trace_callbacks then @@ -122,12 +122,15 @@ callback.register('hpack_filter' , nodes.processors.hpack_filter) local actions = tasks.actions("finalizers") +-- beware, these are packaged boxes so no first_character test +-- maybe some day a hash with valid groupcodes + function nodes.processors.post_linebreak_filter(head,groupcode) -- todo: tail - local first, found = first_character(head) - if found then +--~ local first, found = first_character(head) +--~ if found then if trace_callbacks then local before = nodes.count(head,true) - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) local after = nodes.count(head,true) if done then tracer("finalizer","changed",head,groupcode,before,after,true) @@ -136,14 +139,14 @@ function nodes.processors.post_linebreak_filter(head,groupcode) -- todo: tail end return (done and head) or true else - local head, tail, done = actions(head,slide_nodes(head)) + local head, tail, done = actions(head,slide_nodes(head),groupcode) return (done and head) or true end - elseif trace_callbacks then - local n = nodes.count(head,false) - tracer("finalizer","no chars",head,groupcode,n,n) - end - return true +--~ elseif trace_callbacks then +--~ local n = nodes.count(head,false) +--~ tracer("finalizer","no chars",head,groupcode,n,n) +--~ end +--~ return true end callback.register('post_linebreak_filter', nodes.processors.post_linebreak_filter) diff --git a/tex/context/base/node-res.lua b/tex/context/base/node-res.lua index c8d815be4..b84e5b105 100644 --- a/tex/context/base/node-res.lua +++ b/tex/context/base/node-res.lua @@ -59,6 +59,7 @@ local glue = nodes.register(new_node("glue")) local glue_spec = nodes.register(new_node("glue_spec")) local glyph = nodes.register(new_node("glyph",0)) local textdir = nodes.register(new_node("whatsit",7)) +local rule = nodes.register(new_node("rule")) function nodes.glyph(fnt,chr) local n = copy_node(glyph) @@ -100,6 +101,13 @@ function nodes.textdir(dir) t.dir = dir return t end +function nodes.rule(w,h,d) + local n = copy_node(rule) + if w then n.width = w end + if h then n.height = h end + if d then n.depth = d end + return n +end statistics.register("cleaned up reserved nodes", function() return format("%s nodes, %s lists of %s", nodes.cleanup_reserved(tex.count["lastallocatedbox"])) diff --git a/tex/context/base/node-seq.lua b/tex/context/base/node-seq.lua index 2794c34b9..a4a8ad055 100644 --- a/tex/context/base/node-seq.lua +++ b/tex/context/base/node-seq.lua @@ -142,6 +142,7 @@ function sequencer.nodeprocessor(t) end end local processor = format(template,concat(vars,"\n"),concat(calls,"\n")) +--~ print(processor) return processor end diff --git a/tex/context/base/node-tra.lua b/tex/context/base/node-tra.lua index ef13499f9..3decfd07c 100644 --- a/tex/context/base/node-tra.lua +++ b/tex/context/base/node-tra.lua @@ -275,7 +275,7 @@ function nodes.tracers.steppers.check(head) if collecting then nodes.tracers.steppers.reset() local n = copy_node_list(head) - nodes.inject_kerns(n,nil,true) + nodes.inject_kerns(n,nil,"trace",true) nodes.protect_glyphs(n) -- can be option collection[1] = n end @@ -286,7 +286,7 @@ function nodes.tracers.steppers.register(head) local nc = #collection+1 if messages[nc] then local n = copy_node_list(head) - nodes.inject_kerns(n,nil,true) + nodes.inject_kerns(n,nil,"trace",true) nodes.protect_glyphs(n) -- can be option collection[nc] = n end diff --git a/tex/context/base/node-tsk.lua b/tex/context/base/node-tsk.lua index f20c544c4..c10c0c32e 100644 --- a/tex/context/base/node-tsk.lua +++ b/tex/context/base/node-tsk.lua @@ -97,7 +97,7 @@ tasks.new ( -- "characters", -- "finishers", "fonts", --- "lists", + "lists", "after", -- for users } ) diff --git a/tex/context/base/page-ini.mkii b/tex/context/base/page-ini.mkii index e5c3aa41a..65bc27f53 100644 --- a/tex/context/base/page-ini.mkii +++ b/tex/context/base/page-ini.mkii @@ -824,8 +824,11 @@ \shiftpaperpagebox \pagebox % \v!paper \else \clippagebox \pagebox - \addpagecutmarks \pagebox - \replicatepagebox \pagebox + \doifelse\@@lymarking\v!page + {\replicatepagebox \pagebox + \addpagecutmarks \pagebox} + {\addpagecutmarks \pagebox + \replicatepagebox \pagebox}% \scalepagebox \pagebox \mirrorpaperbox \pagebox \orientpaperbox \pagebox diff --git a/tex/context/base/page-ini.mkiv b/tex/context/base/page-ini.mkiv index 4aedf171e..4c230c1fd 100644 --- a/tex/context/base/page-ini.mkiv +++ b/tex/context/base/page-ini.mkiv @@ -819,8 +819,11 @@ \shiftpaperpagebox \pagebox % \v!paper \else \clippagebox \pagebox - \addpagecutmarks \pagebox - \replicatepagebox \pagebox + \doifelse\@@lymarking\v!page + {\replicatepagebox \pagebox + \addpagecutmarks \pagebox} + {\addpagecutmarks \pagebox + \replicatepagebox \pagebox}% \scalepagebox \pagebox \mirrorpaperbox \pagebox \orientpaperbox \pagebox diff --git a/tex/context/base/page-lay.tex b/tex/context/base/page-lay.tex index 0db7fc167..c8525643f 100644 --- a/tex/context/base/page-lay.tex +++ b/tex/context/base/page-lay.tex @@ -82,29 +82,6 @@ \let\currentlayout\empty -%\def\layoutparameter#1% -% {\ifundefined{\??ly\currentlayout#1}% -% \getvalue{\??ly#1}% -% \else -% \getvalue{\??ly\currentlayout#1}% -% \fi} -% -% faster - -\def\layoutparameter#1% - {\csname\??ly - \ifundefined{\??ly\currentlayout#1}\else\currentlayout\fi - #1\endcsname} - -\def\namedlayoutparameter#1#2% - {\ifundefined{\??ly#1#2}% - \layoutparameter{#2}% - \else - \getvalue{\??ly#1#2}% - \fi} - -%D Look how ugly a speed up looks: - \def\layoutparameter#1% {\csname\??ly\ifcsname \??ly\currentlayout#1\endcsname\currentlayout @@ -595,12 +572,12 @@ \xdef\currentlayout{#1}\recalculatelayout} \def\checkcurrentoddlayout - {\ifundefined{\??ly\v!odd\c!state}\else + {\ifcsname\??ly\v!odd\c!state\endcsname \doifvalue{\??ly\v!odd\c!state}\v!start{\changetolayout\v!odd}% \fi} \def\checkcurrentevenlayout - {\ifundefined{\??ly\v!even\c!state}\else + {\ifcsname\??ly\v!even\c!state\endcsname \doifvalue{\??ly\v!even\c!state}\v!start{\changetolayout\v!even}% \fi} @@ -619,17 +596,6 @@ \!!zerocount \fi} -% \def\checkcurrentlayout % public and used in naw, so keep this name -% {\doifundefinedelse{\??ly\realfolio\c!state} -% {\doifundefinedelse{\??ly\reverserealfolio\c!state} -% {\doifundefinedelse{\??ly\v!current\c!state} -% {\doifoddpageelse\checkcurrentoddlayout\checkcurrentevenlayout} -% {\changetolayout\v!current}} -% {\doifvalue{\??ly\reverserealfolio\c!state}\v!start -% {\changetolayout\reverserealfolio}}} -% {\doifvalue{\??ly\realfolio\c!state}\v!start -% {\changetolayout\realfolio}}} - \def\checkcurrentlayout % public and used in naw, so keep this name {\ifcsname\??ly\realfolio\c!state\endcsname \doifvalue{\??ly\realfolio\c!state}\v!start{\changetolayout\realfolio}% @@ -915,26 +881,34 @@ \let\cutmarkbottomtext\pagecutmarkbottomtext \makecutbox} +\setvalue{\??ly:n:\c!marking:\v!on}% + {\makepagecutbox} + +\setvalue{\??ly:n:\c!marking:\v!page}% only at outer when nx/ny > 0 + {\makepagecutbox} + +\setvalue{\??ly:n:\c!marking:\v!empty}% + {\let\pagecutmarksymbol\empty + \let\pagecutmarktoptext\empty + \let\pagecutmarkbottomtext\empty + \makepagecutbox} + +\setvalue{\??ly:n:\c!marking:\v!text}% + {\let\pagecutmarksymbol\empty + \let\pagecutmarkbottomtext\extrapagecutmarkbottomtext + \makepagecutbox} + +\setvalue{\??ly:c:\c!marking:\v!color}% + {\doaddpagecolormarks\colormarkbox} + +\setvalue{\??ly:c:\c!marking:\v!screen}% + {\doaddpagecolormarks\rastermarkbox} + \def\addpagecutmarks % #1 - {\doifelse\@@lymarking\v!on - \makepagecutbox - {\doifelse\@@lymarking\v!empty - {\let\pagecutmarksymbol\empty - \let\pagecutmarktoptext\empty - \let\pagecutmarkbottomtext\empty - \makepagecutbox} - {\doifelse\@@lymarking\v!text - {\let\pagecutmarksymbol\empty - \let\pagecutmarkbottomtext\extrapagecutmarkbottomtext - \makepagecutbox} - \gobbleoneargument}}} + {\executeifdefined{\??ly:n:\c!marking:\@@lymarking}\gobbleoneargument} \def\addpagecolormarks % #1 - {\doifelse\@@lymarking\v!color - {\doaddpagecolormarks\colormarkbox} - {\doifelse\@@lymarking\v!screen - {\doaddpagecolormarks\rastermarkbox} - \gobbleoneargument}} + {\executeifdefined{\??ly:c:\c!marking:\@@lymarking}\gobbleoneargument} \def\doaddpagecolormarks#1#2% {\makepagecutbox{#2}% @@ -1041,22 +1015,42 @@ % what are those \relax'es doing there? -\def\doifbothsidesoverruled#1#2#3% +% \def\doifbothsidesoverruled#1#2#3% +% {\ifdoublesided +% \doifoddpageelse{#2}{#3}\relax +% \else +% #1\relax +% \fi} + +% \def\doifbothsides#1#2#3% +% {\ifdoublesided +% \ifsinglesided +% #1\relax +% \else +% \doifoddpageelse{#2}{#3}\relax +% \fi +% \else +% #1\relax +% \fi} + +\def\redoifoddpageelse#1{\doifoddpageelse} + +\def\doifbothsidesoverruled {\ifdoublesided - \doifoddpageelse{#2}{#3}\relax + \@EA\redoifoddpageelse \else - #1\relax + \@EA\firstofthreearguments \fi} -\def\doifbothsides#1#2#3% +\def\doifbothsides {\ifdoublesided \ifsinglesided - #1\relax + \@EAEAEA\firstofthreearguments \else - \doifoddpageelse{#2}{#3}\relax + \@EAEAEA\redoifoddpageelse \fi \else - #1\relax + \@EA\firstofthreearguments \fi} \newdimen\texthoffset diff --git a/tex/context/base/page-txt.mkiv b/tex/context/base/page-txt.mkiv index 57bc02882..ab0370316 100644 --- a/tex/context/base/page-txt.mkiv +++ b/tex/context/base/page-txt.mkiv @@ -271,8 +271,18 @@ \fi \endcsname{#1}} % {#2} +% \def\doifelselayouttextline#1% shown or not +% {\doifinsetelse{\getvalue{\??tk#1\c!state}}{\v!normal,\v!start}} + \def\doifelselayouttextline#1% shown or not - {\doifinsetelse{\getvalue{\??tk#1\c!state}}{\v!normal,\v!start}} + {\edef\!!stringa{\csname\??tk#1\c!state\endcsname}% + \ifx\!!stringa\v!normal + \@EA\firstoftwoarguments + \else\ifx\!!stringa\v!start + \@EAEAEA\firstoftwoarguments + \else + \@EAEAEA\secondoftwoarguments + \fi\fi} \def\doifelselayoutsomeline#1% present or not {\edef\!!stringa{\csname\??tk#1\c!state\endcsname}% diff --git a/tex/context/base/s-pre-19.tex b/tex/context/base/s-pre-19.tex index c6ad4f693..dc013d0b3 100644 --- a/tex/context/base/s-pre-19.tex +++ b/tex/context/base/s-pre-19.tex @@ -213,7 +213,6 @@ alternative = 2 : 36pt squeezed squeezeness elseif alternative = 3 : 36pt randomized randomness else : 36pt fi ; - pickup pencircle scaled 3pt ; fill Page withcolor \MPcolor{PageColor} ; @@ -232,7 +231,8 @@ % calls to *_menu_button are generated automatically ... - def right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) = + vardef right_menu_button (expr nn, rr, pp, xx, yy, ww, hh, dd) = + save q ; path q ; if (pp>0) and (rr>0) : q := rightsuperbutton(p,xx,yy,RightEdgeWidth,hh) ; % \MPw{menu:right:\realfolio} fill q withcolor \MPcolor{TextColor} ; diff --git a/tex/context/base/scrn-int.mkiv b/tex/context/base/scrn-int.mkiv index e47f5745e..80f85145b 100644 --- a/tex/context/base/scrn-int.mkiv +++ b/tex/context/base/scrn-int.mkiv @@ -746,7 +746,7 @@ \setlocationboxyes {\??am#1}% % needed ! []% no settings - {\limitatetext{#5}{\getvalue{\??li#2\c!maxwidth}}{\unknown}}% % needed ! + {\limitatetext{#5}{\namedlistparameter{#2}\c!maxwidth}{\unknown}}% % needed ! []}% normally the destination, catch by gobble \@@amboxcommand\do@@amposition{#1}{#7}% beware, we pass the pagenumber {\ignorespaces\linklisttoelement{#3}{#6}{#7}{\box0}\unskip}\\} diff --git a/tex/context/base/strc-lst.mkiv b/tex/context/base/strc-lst.mkiv index 22c189c77..3f829dc20 100644 --- a/tex/context/base/strc-lst.mkiv +++ b/tex/context/base/strc-lst.mkiv @@ -226,7 +226,7 @@ [\c!height=\v!broad, \c!depth=\v!broad, \c!offset=0.25em, - %\c!maxwidth=, + \c!maxwidth=, \c!state=\v!start, \c!coupling=\v!off, \c!criterium=\v!local, @@ -246,13 +246,13 @@ \c!pagecommand=\listpagecommand, \c!pagenumber=\v!yes, \c!headnumber=\v!yes, - %\c!pageboundaries=, + \c!pageboundaries=, \c!margin=\!!zeropoint, - %\c!aligntitle=, - %\c!before=, - %\c!after=, - %\c!inbetween=, - %\c!symbol=, + \c!aligntitle=, + \c!before=, + \c!after=, + \c!inbetween=, + \c!symbol=, \c!interaction=\v!sectionnumber, \c!label=\v!no, \c!distance=\!!zeropoint, @@ -272,10 +272,10 @@ %\c!pageconversionset=, %\c!pagestopper=, %\c!expansion=, - % \c!prefixconnector=., % maybe inherit from setupheads + % \c!prefixconnector=., % maybe inherit from setupheads % \c!pageprefix=\v!no, % is unset, inherits - % \c!pageprefixconnector=\listparameter\c!prefixconnector, - ]% \c!pagesegments=2:2] + % \c!pageprefixconnector=\listparameter\c!prefixconnector, + ]%\c!pagesegments=2:2] \def\definelist {\dotripleempty\dodefinelist} diff --git a/tex/context/base/strc-sec.mkiv b/tex/context/base/strc-sec.mkiv index fd5bee92d..1768325f6 100644 --- a/tex/context/base/strc-sec.mkiv +++ b/tex/context/base/strc-sec.mkiv @@ -338,8 +338,8 @@ \normalexpanded{\noexpand\setmarking[\currentstructureheadcoupling]{\currentstructurelistnumber}}% \currentstructuresynchronize} -\def\thestructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo -\def\thestructureheadtitle {\structurecctvalue{titledata.title}} % todo +\def\fullstructureheadnumber{\labeltexts{\structureheadparameter\c!label}{\structurenumber}} % todo +\def\fullstructureheadtitle {\structurecctvalue{titledata.title}} % todo \let\currentstructurehead \empty \let\currentstructureheadcoupling\empty @@ -387,7 +387,7 @@ \setupinterlinespace % temp hack most be fixed (see s-pre-61) % \begstrut\getmarking[#4#3]\endstrut - \doifelse{#3}\v!number\currentheadnumber\currentheadtext + \doifelse{#3}\v!number\fullstructureheadnumber\fullstructureheadtitle \endgraf \endgroup} @@ -429,9 +429,9 @@ \dostructureheadspacingbeforeyes \doregisterstructurehead{#1}{#2}{#3}% after optional \page \let\getstructureheadsyncs\thestructureheadsynchonization - \let\getstructureheadtitle\thestructureheadtitle + \let\getstructureheadtitle\fullstructureheadtitle \ifconditional\structureheadshownumber - \let\getstructureheadnumber\thestructureheadnumber + \let\getstructureheadnumber\fullstructureheadnumber \placestructureheadnumbertext \else \placestructureheadtext @@ -448,8 +448,8 @@ \ifconditional\structureheaddoplace \dostructureheadspacingbeforeyes \doregisterstructurehead{#1}{#2}{#3}% after optional \page - \let\getstructureheadtitle\thestructureheadtitle \let\getstructureheadsyncs\thestructureheadsynchonization + \let\getstructureheadtitle\fullstructureheadtitle \placestructureheadtext \dostructureheadspacingafteryes \else @@ -637,7 +637,11 @@ \def\currentstructureheadnumber{0} % ==> \currentheadnumber \def\determineheadnumber[#1]% - {\xdef\currentstructureheadnumber{\getstructurenumber{\thecurrentstructureheadlevel{#1}}}} + {\xdef\currentstructureheadnumber{\getstructurenumber{\thenamedstructureheadlevel{#1}}}} + +% The previous macro is been replaced by the expandable: + +\def\namedheadnumber#1{\getstructurenumber{\thenamedstructureheadlevel{#1}}} \def\structureheadnumber {\dosingleempty\dostructureheadnumber} @@ -646,6 +650,8 @@ {\getfullstructurenumber{\iffirstargument\thecurrentstructureheadlevel{#1}\fi}} % compatibility code (after all, we might offer different structure handlers as well +% but we might as well remove the 'structure' substring at some point (we needed it +% in order to test the old and new methods alongside) \let\definesectionblock \definestructureblock \let\definesection \definestructuresection @@ -655,10 +661,12 @@ \let\setuphead \setupstructurehead \let\headnumber \structureheadnumber \let\setupsectionblock \setupstructureblock -\let\currentheadnumber \thestructureheadnumber -\let\currentheadtext \thestructureheadtitle + \let\sectioncountervalue\structurevalue +\def\currentheadnumber {\currentstructureheadnumber} +\def\currentheadtext {obsolete, use marks} + % list references, will be redone in lua when we need it \let\startlistreferences\relax diff --git a/tex/context/base/syst-aux.mkiv b/tex/context/base/syst-aux.mkiv index c6a7c2499..620c43eef 100644 --- a/tex/context/base/syst-aux.mkiv +++ b/tex/context/base/syst-aux.mkiv @@ -104,6 +104,8 @@ \def\!!zerocount {0} % alongside \zerocount \def\!!minusone {-1} % alongside \minusone \def\!!plusone {1} % alongside \plusone +\def\!!plustwo {2} % alongside \plustwo +\def\!!plusthree {3} % alongside \plusthree \ifdefined\data \else \let\data \relax \fi % dep checker diff --git a/tex/context/base/tabl-tbl.tex b/tex/context/base/tabl-tbl.tex index bc57a3abd..15e827e68 100644 --- a/tex/context/base/tabl-tbl.tex +++ b/tex/context/base/tabl-tbl.tex @@ -542,7 +542,7 @@ \expandafter\nexttabulate \fi} -\def\splitofftabulatebox +\def\splitofftabulatebox % overloaded in anch-pgr {\dontcomplain \global\setbox\tabulatebox % % % global ? % % % \vsplit\tablebox\tabulatecolumn to \lineheight @@ -954,6 +954,8 @@ \bgroup \catcode`\|=\@@other +\newtoks\everyaftertabulaterow + \gdef\processtabulate[|#1|]% in the process of optimizing {\tabulateunit\tabulateparameter\c!unit \checkfulltabulatecontent @@ -1014,6 +1016,8 @@ \global\tabulatecolumn\zerocount \resettabulatepheight \unskip\unskip\crcr\flushtabulated +\TABLEnoalign + {\the\everyaftertabulaterow}% \TABLEnoalign {\iftolerantTABLEbreak\else \ifconditional\tabulatesomeamble \ifcase\tabulaterepeathead \else diff --git a/tex/context/interface/cont-cs.xml b/tex/context/interface/cont-cs.xml index caa4fbd45..15700ee08 100644 --- a/tex/context/interface/cont-cs.xml +++ b/tex/context/interface/cont-cs.xml @@ -3893,6 +3893,7 @@ <cd:constant type="barevne"/> <cd:constant type="rastr"/> <cd:constant type="cd:text"/> + <cd:constant type="stranka"/> </cd:parameter> <cd:parameter name="misto"> <cd:constant type="vlevo"/> diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml index 8063ae406..ace1fb315 100644 --- a/tex/context/interface/cont-de.xml +++ b/tex/context/interface/cont-de.xml @@ -3893,6 +3893,7 @@ <cd:constant type="farbe"/> <cd:constant type="raster"/> <cd:constant type="cd:text"/> + <cd:constant type="seite"/> </cd:parameter> <cd:parameter name="platz"> <cd:constant type="links"/> diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml index 64129b064..6e3ac4db7 100644 --- a/tex/context/interface/cont-en.xml +++ b/tex/context/interface/cont-en.xml @@ -3893,6 +3893,7 @@ <cd:constant type="color"/> <cd:constant type="screen"/> <cd:constant type="cd:text"/> + <cd:constant type="page"/> </cd:parameter> <cd:parameter name="location"> <cd:constant type="left"/> diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml index 1d552f1e1..bd14281c9 100644 --- a/tex/context/interface/cont-fr.xml +++ b/tex/context/interface/cont-fr.xml @@ -3893,6 +3893,7 @@ <cd:constant type="couleur"/> <cd:constant type="ecran"/> <cd:constant type="cd:text"/> + <cd:constant type="page"/> </cd:parameter> <cd:parameter name="emplacement"> <cd:constant type="gauche"/> diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml index 8210a0f88..47ec1ffdd 100644 --- a/tex/context/interface/cont-it.xml +++ b/tex/context/interface/cont-it.xml @@ -3893,6 +3893,7 @@ <cd:constant type="colore"/> <cd:constant type="schermo"/> <cd:constant type="cd:text"/> + <cd:constant type="pagina"/> </cd:parameter> <cd:parameter name="luogo"> <cd:constant type="sinistra"/> diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml index eab751a8f..df538ad8f 100644 --- a/tex/context/interface/cont-nl.xml +++ b/tex/context/interface/cont-nl.xml @@ -3893,6 +3893,7 @@ <cd:constant type="kleur"/> <cd:constant type="raster"/> <cd:constant type="cd:text"/> + <cd:constant type="pagina"/> </cd:parameter> <cd:parameter name="plaats"> <cd:constant type="links"/> diff --git a/tex/context/interface/cont-pe.xml b/tex/context/interface/cont-pe.xml index c8f4a782a..df7d55387 100644 --- a/tex/context/interface/cont-pe.xml +++ b/tex/context/interface/cont-pe.xml @@ -3893,6 +3893,7 @@ <cd:constant type="رنگ"/> <cd:constant type="پرده"/> <cd:constant type="cd:text"/> + <cd:constant type="صفحه"/> </cd:parameter> <cd:parameter name="مکان"> <cd:constant type="چپ"/> diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml index 19f007e95..726c3f272 100644 --- a/tex/context/interface/cont-ro.xml +++ b/tex/context/interface/cont-ro.xml @@ -3893,6 +3893,7 @@ <cd:constant type="culoare"/> <cd:constant type="ecran"/> <cd:constant type="cd:text"/> + <cd:constant type="pagina"/> </cd:parameter> <cd:parameter name="locatie"> <cd:constant type="stanga"/> diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index 08b079f9e..06a81b123 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 06/07/09 13:14:18 +-- merge date : 06/10/09 11:24:52 do -- begin closure to overcome local limits and interference @@ -232,6 +232,11 @@ function string.tabtospace(str,tab) return str end +function string:compactlong() -- strips newlines and leading spaces + self = gsub(self,"[\n\r]+ *","") + self = gsub(self,"^ *","") + return self +end end -- closure @@ -2210,6 +2215,7 @@ local glue = nodes.register(new_node("glue")) local glue_spec = nodes.register(new_node("glue_spec")) local glyph = nodes.register(new_node("glyph",0)) local textdir = nodes.register(new_node("whatsit",7)) +local rule = nodes.register(new_node("rule")) function nodes.glyph(fnt,chr) local n = copy_node(glyph) @@ -2251,6 +2257,13 @@ function nodes.textdir(dir) t.dir = dir return t end +function nodes.rule(w,h,d) + local n = copy_node(rule) + if w then n.width = w end + if h then n.height = h end + if d then n.depth = d end + return n +end statistics.register("cleaned up reserved nodes", function() return format("%s nodes, %s lists of %s", nodes.cleanup_reserved(tex.count["lastallocatedbox"])) @@ -2434,7 +2447,7 @@ end -- todo: reuse tables (i.e. no collection), but will be extra fields anyway -function nodes.inject_kerns(head,tail,keep) +function nodes.inject_kerns(head,tail,where,keep) if trace_injections then nodes.trace_injection(head) end @@ -2442,10 +2455,10 @@ function nodes.inject_kerns(head,tail,keep) if has_marks or has_cursives then -- in the future variant we will not copy items but refs to tables local done, ky, rl, valid, cx, wx = false, { }, { }, { }, { }, { } - for n in traverse_id(glyph,head) do - if n.subtype < 256 then - valid[#valid+1] = n - if has_kerns then -- move outside loop + if has_kerns then -- move outside loop + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n local k = has_attribute(n,kernpair) if k then local kk = kerns[k] @@ -2463,6 +2476,12 @@ function nodes.inject_kerns(head,tail,keep) end end end + else + for n in traverse_id(glyph,head) do + if n.subtype < 256 then + valid[#valid+1] = n + end + end end if #valid > 0 then -- we can assume done == true because we have cursives and marks @@ -2481,6 +2500,7 @@ function nodes.inject_kerns(head,tail,keep) n = valid[i] if n.font ~= nf then nf = n.font +--~ print(n.font,nf,fontdata[nf]) tm = fontdata[nf].marks -- maybe flush maxt = 0 @@ -10807,6 +10827,7 @@ function define.read(specification,size,id) -- id can be optional, name can alre fontdata.encodingname or "unicode", fontdata.fullname or "?", file.basename(fontdata.filename or "?")) + end statistics.stoptiming(fonts) return fontdata |