summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-12-31 10:20:13 +0200
committerMarius <mariausol@gmail.com>2010-12-31 10:20:13 +0200
commitf67b9a6b70277a30f7e7ef9a7a3913447ee525f8 (patch)
treeb73bbc8ae4ad8cbeb78693b84b81fa4ff3044ab7
parentab00ef13e506bf34d8928b536c3e20d228e26422 (diff)
downloadcontext-f67b9a6b70277a30f7e7ef9a7a3913447ee525f8.tar.gz
beta 2010.12.31 08:59
-rw-r--r--tex/context/base/attr-col.lua2
-rw-r--r--tex/context/base/cldf-com.lua20
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex2
-rw-r--r--tex/context/base/font-chk.lua2
-rw-r--r--tex/context/base/font-ini.mkiv87
-rw-r--r--tex/context/base/s-mod-00.mkii (renamed from tex/context/base/s-mod-00.tex)6
-rw-r--r--tex/context/base/s-mod-00.mkiv481
-rw-r--r--tex/context/base/s-mod-01.mkii (renamed from tex/context/base/s-mod-01.tex)4
-rw-r--r--tex/context/base/s-mod-01.mkiv146
-rw-r--r--tex/context/base/s-mod-02.mkii (renamed from tex/context/base/s-mod-02.tex)0
-rw-r--r--tex/context/base/s-mod-02.mkiv421
-rw-r--r--tex/context/base/type-otf.mkiv1
-rw-r--r--tex/generic/context/luatex-fonts-merged.lua2
-rw-r--r--tex/generic/context/luatex-mplib.lua491
15 files changed, 1625 insertions, 42 deletions
diff --git a/tex/context/base/attr-col.lua b/tex/context/base/attr-col.lua
index 0a60ba52a..d4f1c1198 100644
--- a/tex/context/base/attr-col.lua
+++ b/tex/context/base/attr-col.lua
@@ -508,7 +508,7 @@ end
commands.enablecolor = colors.enable
commands.enabletransparency = transparencies.enable
-commands.enablecolorintent = colorintents.enable
+commands.enablecolorintents = colorintents.enable
function commands.registercolor (...) context(colors .register(...)) end
function commands.registertransparency(...) context(transparencies.register(...)) end
diff --git a/tex/context/base/cldf-com.lua b/tex/context/base/cldf-com.lua
index d64b75ee6..caffe44ce 100644
--- a/tex/context/base/cldf-com.lua
+++ b/tex/context/base/cldf-com.lua
@@ -83,3 +83,23 @@ function context.hrule(w,h,d,dir)
end
context.vrule = context.hrule
+
+--~ local hbox, bgroup, egroup = context.hbox, context.bgroup, context.egroup
+
+--~ function context.hbox(a,...)
+--~ if type(a) == "table" then
+--~ local s = { }
+--~ if a.width then
+--~ s[#s+1] = "to " .. a.width -- todo: check for number
+--~ elseif a.spread then
+--~ s[#s+1] = "spread " .. a.spread -- todo: check for number
+--~ end
+--~ -- todo: dir, attr etc
+--~ hbox(false,table.concat(s," "))
+--~ bgroup()
+--~ context(string.format(...))
+--~ egroup()
+--~ else
+--~ hbox(a,...)
+--~ end
+--~ end
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index e45976994..f30487135 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{2010.12.22 20:18}
+\newcontextversion{2010.12.31 08:59}
%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.tex b/tex/context/base/context.tex
index 582b645f2..cf8581536 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{2010.12.22 20:18}
+\edef\contextversion{2010.12.31 08:59}
%D For those who want to use this:
diff --git a/tex/context/base/font-chk.lua b/tex/context/base/font-chk.lua
index 78b3253c5..b8a4e924c 100644
--- a/tex/context/base/font-chk.lua
+++ b/tex/context/base/font-chk.lua
@@ -49,7 +49,7 @@ local function registermessage(font,char,message)
end
end
-local registermessage = fonts.registermessage
+fonts.registermessage = registermessage
function checkers.missing(head)
if checkers.enabled then
diff --git a/tex/context/base/font-ini.mkiv b/tex/context/base/font-ini.mkiv
index 932f471ef..667bce92b 100644
--- a/tex/context/base/font-ini.mkiv
+++ b/tex/context/base/font-ini.mkiv
@@ -1450,7 +1450,7 @@
\@@beginfontdef
\doifelse{#2}\s!default
{\getparameters[\??ft\s!default][#3]}
- {\normalizebodyfontsize#2\to\tempbodyfontsize
+ {\edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}%
\addtocommalist\tempbodyfontsize\bodyfontenvironmentlist
\@EA\dododefinebodyfontenvironment\@EA[\tempbodyfontsize][#1][#3]}%
\@@endfontdef
@@ -1473,7 +1473,7 @@
% but some day we will clean this up anyway
\def\docommand##1%
{\scratchdimen\csname\??ft\s!default##1\endcsname\dimexpr#1\relax
- \normalizebodyfontsize\scratchdimen\to\tempbodyfontsize
+ \edef\tempbodyfontsize{\thenormalizedbodyfontsize\scratchdimen}%
\letvalue{\??ft#2#1##1}\tempbodyfontsize}%
\processcommacommand[\fontrelativesizelist]\docommand
\copyparameters
@@ -1518,15 +1518,44 @@
%D So, apart from an occasional switch, one should define an
%D environment at the outer level.
-\def\checkbodyfontenvironment[#1]%
- {\definebodyfontenvironment[\fontclass][#1][]}
+% \def\checkbodyfontenvironment[#1]%
+% {\definebodyfontenvironment[\fontclass][#1][]}
+%
+% \def\checkbodyfontenvironment[#1]%
+% {\ifcsname\??ft\fontclass#1\c!em\endcsname
+% % we test for em as we assume it to be set
+% \else
+% \definebodyfontenvironment[\fontclass][#1][]%
+% \fi}
+%
+% will be adapted with parent chain:
\def\checkbodyfontenvironment[#1]%
- {\ifcsname\??ft\fontclass#1\c!em\endcsname
- % we test for em as we assume it to be set
- \else
- \definebodyfontenvironment[\fontclass][#1][]%
- \fi}
+ {\ifcsname\??ft #1\c!em\endcsname\else\docheckbodyfontenvironment\empty {#1}\fi
+ \ifcsname\??ft\fontclass#1\c!em\endcsname\else\docheckbodyfontenvironment\fontclass{#1}\fi}
+
+\def\docheckbodyfontenvironment#1#2% class size (simplified version of definebodyfontenvironment)
+ {\@@beginfontdef
+ \edef\tempbodyfontsize{\thenormalizedbodyfontsize{#2}}%
+ \addtocommalist\tempbodyfontsize\bodyfontenvironmentlist
+ \def\docommand##1% text script scriptscript x xx big small
+ {\setevalue{\??ft#1\tempbodyfontsize##1}%
+ {\thenormalizedbodyfontsize{\csname\??ft\s!default##1\endcsname\dimexpr\tempbodyfontsize\relax}}}%
+ \processcommacommand[\fontrelativesizelist]\docommand
+ \copyparameters % can inherit
+ [\??ft#1\tempbodyfontsize][\??ft\s!default]
+ [\c!interlinespace,\c!em]%
+% \ifproductionrun
+ \ifcsname\@size@\tempbodyfontsize\endcsname \else
+ \letvalueempty{\@size@\tempbodyfontsize}% prevent loop
+ \pushmacro\fontclass
+ \edef\fontclass{#1}%
+ \normalexpanded{\defineunknownfont{\tempbodyfontsize}}% we can also inherit here
+ \popmacro\fontclass
+ \fi
+% \fi
+ \setevalue{\@size@#1}{\noexpand\docompletefontswitch[#1]}%
+ \@@endfontdef}
% this one already catches both define/setup
@@ -1534,6 +1563,16 @@
%D Just a couple of interface macros:
+% todo:
+%
+% \letvalueempty{\??ft\s!empty}
+%
+% \def\currentbodyfontvariable#1%
+% {\csname\??ft
+% \ifcsname\??ft\fontclass#1\endcsname\fontclass#1\else
+% \ifcsname\??ft #1\endcsname #1\else \s!empty \fi
+% \fi}
+
\def\bodyfontvariable#1%
{\??ft\ifcsname\??ft\fontclass#1\endcsname\fontclass\fi#1}
@@ -1805,7 +1844,7 @@
\def\dodefineunknownfont#1#2%
{\ifcsname\??ft\s!default#2\endcsname
\donetrue
- \normalizebodyfontsize\csname\??ft\s!default#2\endcsname\dimexpr#1\relax\to\tempbodyfontsize
+ \edef\tempbodyfontsize{\thenormalizedbodyfontsize{\csname\??ft\s!default#2\endcsname\dimexpr#1\relax}}%
\letvalue{\??ft#1#2}\tempbodyfontsize
\fi}
@@ -1930,9 +1969,9 @@
\def\thenormalizedbodyfontsize#1%
{\ctxlua{fonts.nbfs(\number\dimexpr#1\relax,\number\fontdigits)}}
-\normalizebodyfontsize\bodyfontsize\to\normalizedglobalbodyfontsize
-\normalizebodyfontsize\bodyfontsize\to\normalizedlocalbodyfontsize
-\normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize
+\edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}
+\edef\normalizedlocalbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
+\edef\normalizedbodyfontsize {\thenormalizedbodyfontsize\bodyfontsize}
%D \macros
%D {fontstyle,fontalternative,fontsize}
@@ -1976,8 +2015,8 @@
\ifcsname\@size@#1\endcsname
\csname\@size@#1\endcsname
\localbodyfontsize#1\relax
- \normalizebodyfontsize\localbodyfontsize\to\normalizedbodyfontsize
% \edef\fontbody{\fontbody}% to be tested but we can clean up mkiv further
+ \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\localbodyfontsize}%
\checkbodyfontenvironment[\normalizedbodyfontsize]%
\else
\showmessage\m!fonts4{#1}%
@@ -2060,7 +2099,7 @@
{\resetpreloadfonts
\usetypescript[modern]%
\setuptypeface[modern]%
- %\setuptypeface[\s!default]%
+ %\setupbodyfont[modern]%
\showmessage\m!fonts6{\normalizedbodyfontsize\normalspace\fontstyle}}
\def\resetpreloadfonts
@@ -2156,7 +2195,7 @@
\fi\fi}
\def\dodododosetfont#1#2#3% #1 = set/switch state
- {\normalizebodyfontsize#2\to\normalizedsetfont
+ {\edef\normalizedsetfont{\thenormalizedbodyfontsize{#2}}%
\ifcsname\@size@\normalizedsetfont\endcsname \else
\defineunknownfont{#2}%
\fi
@@ -2223,18 +2262,6 @@
\settrue\autotypescripts
-% \def\trycurrentfontclass#1%
-% {\ifconditional\autotypescripts
-% \usetypescript[#1]%
-% \ifcsname\@fontclass@#1\endcsname
-% \edef\fontclass{#1}%
-% \else
-% \letvalueempty{\@no@fontclass@#1}%
-% \fi
-% \else
-% \letvalueempty{\@no@fontclass@#1}%
-% \fi}
-
\def\trycurrentfontclass#1%
{\ifconditional\autotypescripts
% try to load typescript #1
@@ -2646,7 +2673,7 @@
{\bodyfontsize#1\relax
\dimensiontocount\bodyfontsize\bodyfontpoints % rounded, still used in m-chart
\edef\bodyfontfactor{\withoutpt\the\bodyfontsize}%
- \normalizebodyfontsize\bodyfontsize\to\normalizedbodyfontsize
+ \edef\normalizedbodyfontsize{\thenormalizedbodyfontsize\bodyfontsize}%
\dosetbodyfontface \textface \s!text
\dosetbodyfontface \scriptface \s!script
\dosetbodyfontface \scriptscriptface \s!scriptscript}
@@ -2695,7 +2722,7 @@
{\doifsomething{#1}
{\dosetfont1{#1}%
\globalbodyfontsize\localbodyfontsize
- \normalizebodyfontsize\globalbodyfontsize\to\normalizedglobalbodyfontsize
+ \edef\normalizedglobalbodyfontsize{\thenormalizedbodyfontsize\globalbodyfontsize}%
\let\globalfontstyle\fontstyle
\ifproductionrun
\the\everybodyfont
diff --git a/tex/context/base/s-mod-00.tex b/tex/context/base/s-mod-00.mkii
index 5ce7dcdf4..e2d07200c 100644
--- a/tex/context/base/s-mod-00.tex
+++ b/tex/context/base/s-mod-00.mkii
@@ -22,10 +22,8 @@
\usemodule[units]
-\doifnotmode{mkiv}{
- \enableactivediscretionaries
- \newprettytrue
-}
+\enableactivediscretionaries
+\newprettytrue
\unprotect
diff --git a/tex/context/base/s-mod-00.mkiv b/tex/context/base/s-mod-00.mkiv
new file mode 100644
index 000000000..f6b6f7ba2
--- /dev/null
+++ b/tex/context/base/s-mod-00.mkiv
@@ -0,0 +1,481 @@
+%D \module
+%D [ file=s-mod-00,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Documentation Base Environment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module looks like crap, is not documented, will
+%D change, and used to be called modu-*.tex.
+
+% now split in mkii/mkiv so we will cleanup
+
+\mainlanguage[en] % better not here
+
+\usemodule[units]
+
+\unprotect
+
+% beter:
+%
+% group -> title
+% title -> category
+% subtitle -> subtitle
+
+% herzien ivm fonts
+
+% nog eens \interface \\ \\ verder doorvoeren
+
+\def\resetmodule
+ {\getrawparameters
+ [Module]
+ [ file=\jobname,
+ type=,
+ version={\currentdate[\v!year,{.},\v!month,{.},\v!day]},
+ system=\CONTEXT,
+ title=Unknown Title,
+ subtitle=,
+ author=Unknown Author,
+ date=\currentdate,
+ copyright=Unknown Copyright,
+ suggestions=]}
+
+\resetmodule
+
+\def\dostartmodule[#1]%
+ {\newcounter\ParagraphNumber
+ \resetmodule
+ \getrawparameters[Module][type=tex,#1]}
+
+\def\startmodule
+ {\starttext
+ \dosingleempty\dostartmodule}
+
+\def\complexmodule[#1]%
+ {\startglobal % i.v.m. \bgroup in \startdocumentation
+ \getrawparameters[Module][#1]
+ \stopglobal % i.v.m. \bgroup in \startdocumentation
+ \moduletitle}
+
+\def\stopmodule
+ {\page
+ \placeregister
+ [\v!index]
+ [\c!balance=\v!yes,
+ \c!indicator=\v!no,
+ \c!criterium=\v!text]
+ \stoptext}
+
+\def\simplemodule#1%
+ {\type{#1}}
+
+\definecomplexorsimple\module
+
+\startuseMPgraphic{titlepage}
+
+ width := PaperWidth ;
+ height := PaperHeight ;
+
+ color local_red, local_white, local_blue ;
+
+ local_white := white ;
+
+ local_blue := local_white randomized (.6,.8) ;
+ local_red := local_white randomized (.3,.4) ;
+
+ u := width/400 ;
+
+ def a_module (expr dx, dy) =
+ picture p ; p := image
+ ( ddy := 0 ; sx := 60u ;
+ for i=1 upto (4 randomized 2) :
+ sy := 7u randomized 3u ;
+ fill unitsquare xyscaled(sx,sy) shifted (0,ddy)
+ withcolor local_red ;
+ ddy := ddy + sy + 4u ;
+ endfor ) ;
+ p := p shifted (dx,dy) shifted - center p ;
+ fill boundingbox p enlarged 8u withcolor local_white ;
+ fill boundingbox p enlarged 4u withcolor local_blue ;
+ draw p ;
+ enddef ;
+
+ set_grid(width, height, width/15, height/15) ;
+ forever:
+ if new_on_grid(uniformdeviate width,uniformdeviate height):
+ a_module(dx,dy) ;
+ fi ;
+ exitif grid_full ;
+ endfor ;
+
+ clip currentpicture to unitsquare xyscaled(width,height) ;
+\stopuseMPgraphic
+
+\defineoverlay
+ [titlepage]
+ [\useMPgraphic{titlepage}]
+
+\doifmode{atpragma}{\readfile{s-mod-04.tex}{}{}}
+
+\defineframed
+ [TitleFrame]
+ [\c!background=\v!color,
+ \c!backgroundcolor=white,
+ \c!align=\v!right,
+ \c!offset=12pt,
+ \c!strut=\v!no,
+ \c!frame=\v!off,
+ \c!bottom=]
+
+\definelayout
+ [titlepage]
+ [\c!backspace=0pt,
+ \c!topspace=0pt,
+ \c!header=0pt,
+ \c!footer=0pt,
+ \c!height=\v!middle,
+ \c!width=\v!middle]
+
+\def\moduletitle
+ {\setuplayout[titlepage]
+ \ifx\ModuleNumber\undefined \else
+ \ifnum\ModuleNumber<10
+ \edef\ModuleNumber{00\ModuleNumber}
+ \else\ifnum\ModuleNumber<100
+ \edef\ModuleNumber{0\ModuleNumber}
+ \fi\fi
+ \setupbackgrounds
+ [\v!page]
+ [\c!background=titlepage]
+ \fi
+ \startmakeup[\v!standard][\c!headerstate=\v!none,\c!footerstate=\v!none]
+ \switchtobodyfont[14.4pt,ss]
+ \bgroup
+ \def\CONTEXT {Con\kern-.15em\TeX t}
+ \def\TEXUTIL {\TeX Util}
+ \def\PPCHTEX {PPCH\TeX}
+ \def\METAPOST{MetaPost}
+ \hfill
+ {\definedfont[SansBold at 96pt]\setstrut
+ \TitleFrame{\Modulesystem}}
+ \vfill
+ \definetabulate[temp][|l|l|]%
+ \switchtobodyfont[17.3pt,ss]
+ \hfill
+ {\bf\setstrut
+ \TitleFrame
+ {\insidefloattrue\setuptabulate[\c!before=,\c!after=]%
+ \starttemp
+ \doifsomething{\Moduletitle}
+ {\NC title \EQ \Moduletitle \NC\NR}%
+ \doifsomething{\Modulesubtitle}
+ {\NC subtitle \EQ \Modulesubtitle \NC\NR}%
+ \doifsomething{\Moduleauthor}
+ {\NC author \EQ \Moduleauthor \NC\NR}%
+ \NC date \EQ \currentdate \NC\NR
+ %\doifsomething{\Modulesuggestions} % todo: generates space
+ % {\NC suggestions \NC \Modulesuggestions \NC\NR}%
+ \stoptemp}}
+ \egroup
+ \stopmakeup
+ \ifx\ModuleNumber\undefined \else
+ \setupbackgrounds
+ [\v!page]
+ [\c!background=]
+ \fi
+ \setuplayout}
+
+\let\stopdocumentation=\relax
+
+\def\startdocumentation
+ {\bgroup
+ \doglobal\newcounter\NOfMarginLines
+ \def\stopdocumentation{\par\egroup}}
+
+\newif\ifcompressdefinitions
+
+\def\startcompressdefinitions {\global\compressdefinitionstrue}
+\def\stopcompressdefinitions {\global\compressdefinitionsfalse}
+
+\gdef\CompressDefinitions%
+ {\ifcompressdefinitions
+ \switchtobodyfont[\v!small]%
+ \fi}
+
+\startnotmode[nocode]
+
+ \definetyping
+ [definition]
+
+ \setuptyping
+ [definition]
+ [\c!before={\page[\v!preference]}\blank\PresetParagraphNumber\CompressDefinitions,
+ \c!after=\ResetParagraphNumber\blank,
+ \c!option=\Moduletype]
+
+\stopnotmode
+
+\startmode[nocode]
+
+ \long\def\startdefinition#1\stopdefinition{}
+
+\stopmode
+
+\definetyping [PL] [\c!option=PL, \c!margin=\v!standard]
+\definetyping [JV] [\c!option=JV, \c!margin=\v!standard]
+\definetyping [MP] [\c!option=MP, \c!margin=\v!standard]
+\definetyping [TEX] [\c!option=TEX,\c!margin=\v!standard]
+
+\setuptyping [\v!typing] [\c!margin=\v!standard]
+\setuptyping [\v!file] [\c!margin=\v!standard]
+\setuptyping [definition] [\c!margin=0pt]
+
+\newcounter\NOfMarginLines
+\newcounter\ParagraphNumber
+
+\def\ResetParagraphNumber
+ {\egroup}
+
+\def\PresetParagraphNumber
+ {\bgroup
+ \xdef\NOfTextLines%
+ {\the\prevgraf}%
+ \doglobal\decrement\NOfMarginLines
+ \doglobal\increment\ParagraphNumber
+ \message{.}%
+ \gdef\ShowParagraphNumber%
+ {\llap{\slx\ParagraphNumber\hskip\leftmargindistance}}%
+ \gdef\ShowParagraphNumberA%
+ {\ifnum\NOfMarginLines>\NOfTextLines\relax
+ \doglobal\increment\NOfTextLines
+ \else
+ \ShowParagraphNumber
+ \global\let\ShowParagraphNumberA=\relax
+ \global\let\ShowParagraphNumberB=\ShowParagraphNumber
+ \doglobal\newcounter\NOfMarginLines
+ \fi}%
+ \gdef\ShowParagraphNumberB%
+ {}%
+ \EveryLine
+ {\ShowParagraphNumberA}%
+ \EveryPar
+ {\vadjust{\nobreak}%
+ \ShowParagraphNumberB}}
+
+\EveryPar % skip one
+ {\EveryPar
+ {\doglobal\newcounter\NOfMarginLines}}
+
+\def\dodomargeaanduidingen[#1]#2%
+ {\def\docommand##1%
+ {\indent\hbox
+ {\ifx#2\relax
+ \index{##1}%
+ \else
+ \index{#2{##1}}%
+ \fi
+ #2{\doboundtext{##1}{\leftmarginwidth}{..}}}%
+ \doglobal\increment\NOfMarginLines
+ \endgraf}%
+ \processcommalist[#1]\docommand}
+
+\def\margeaanduidingen#1[#2]%
+ {\def\domargeaanduidingen##1##2%
+ {\margintitle[#2]%
+ {\switchtobodyfont[\v!small]%
+ \doglobal\newcounter\NOfMarginLines
+ \dodomargeaanduidingen[##1]#1%
+ \scratchcounter=\NOfMarginLines
+ \multiply\scratchcounter by 10
+ \divide\scratchcounter by 12
+ \advance\scratchcounter by 1
+ \xdef\NOfMarginLines{\the\scratchcounter}%
+ \processcommalist[##2]\index}}%
+ \dodoublegroupempty\domargeaanduidingen}
+
+\def\complexmacros{\margeaanduidingen\tex }
+\def\complexextras{\margeaanduidingen\relax}
+
+\def\complexelements
+ {\margeaanduidingen\someelement}
+
+\def\someelement#1{\type{<#1>}}
+
+\definecomplexorsimpleempty\macros
+\definecomplexorsimpleempty\extras
+\definecomplexorsimpleempty\elements
+
+\def\showelements{\dodoubleempty\doshowelements}
+
+\def\doshowelements[#1][#2]
+ {\bgroup
+ \processXMLbuffer
+ \typebuffer
+ \setupcolors[\c!state=\v!stop]
+ \showXSDcomponent[#1][#2]
+ \egroup}
+
+% \macros{a,b}
+% \macros{a,b}{b}
+% \macros[a]{a,b}{b}
+
+% weg ermee
+
+\defineparagraphs [interface] [\c!n=2]
+\setupparagraphs [interface] [1] [\c!width=4cm]
+
+\def\startexample{\par\startnarrower} \let\startvoorbeeld\startexample
+\def\stopexample {\stopnarrower} \let\stopvoorbeeld \stopexample
+
+\gdef\VisualizeLastSpace{\ifdim\lastskip>0pt\unskip\tttf\char32\fi}
+
+\gdef\ShowHeadText #1{\tttf#1\VL\mainlanguage[\currentlanguage]\headtext {#1}\VisualizeLastSpace}
+\gdef\ShowLabelText#1{\tttf#1\VL\mainlanguage[\currentlanguage]\labeltext{#1}\VisualizeLastSpace}
+
+\startbuffer[lang-a]
+\starttable[|l|l|]
+ \HL
+ \VL \bf head key \VL \bf current value \VL\SR
+ \HL
+ \VL \ShowHeadText \v!abbreviations \VL\FR
+ \VL \ShowHeadText \v!units \VL\MR
+ \VL \ShowHeadText \v!figures \VL\MR
+ \VL \ShowHeadText \v!graphics \VL\MR
+ \VL \ShowHeadText \v!index \VL\MR
+ \VL \ShowHeadText \v!content \VL\MR
+ \VL \ShowHeadText \v!intermezzi \VL\MR
+ \VL \ShowHeadText \v!logos \VL\MR
+ \VL \ShowHeadText \v!tables \VL\LR
+ \HL
+\stoptable
+\stopbuffer
+
+\startbuffer[lang-b]
+\starttable[|l|l|]
+ \HL
+ \VL \bf label key \VL \bf current value \VL\SR
+ \HL
+ \VL \ShowLabelText \v!table \VL\FR
+ \VL \ShowLabelText \v!figure \VL\MR
+ \VL \ShowLabelText \v!intermezzo \VL\MR
+ \VL \ShowLabelText \v!graphic \VL\MR
+ \VL \ShowLabelText \v!chapter \VL\MR
+ \VL \ShowLabelText \v!section \VL\MR
+ \VL \ShowLabelText \v!subsection \VL\MR
+ \VL \ShowLabelText \v!subsubsection \VL\MR
+ \VL \ShowLabelText \v!appendix \VL\MR
+ \VL \ShowLabelText \v!part \VL\MR
+ \VL \ShowLabelText \v!line \VL\MR
+ \VL \ShowLabelText \v!lines \VL\LR
+ \HL
+\stoptable
+\stopbuffer
+
+\startbuffer[lang-c]
+\starttable[|l|l|]
+ \HL
+ \VL \bf label key \VL \bf current value \VL\SR
+ \HL
+ \VL \ShowLabelText \v!january \VL\FR
+ \VL \ShowLabelText \v!february \VL\MR
+ \VL \ShowLabelText \v!march \VL\MR
+ \VL \ShowLabelText \v!april \VL\MR
+ \VL \ShowLabelText \v!may \VL\MR
+ \VL \ShowLabelText \v!june \VL\MR
+ \VL \ShowLabelText \v!july \VL\MR
+ \VL \ShowLabelText \v!august \VL\MR
+ \VL \ShowLabelText \v!september \VL\MR
+ \VL \ShowLabelText \v!october \VL\MR
+ \VL \ShowLabelText \v!november \VL\MR
+ \VL \ShowLabelText \v!december \VL\LR
+ \HL
+\stoptable
+\stopbuffer
+
+\startbuffer[lang-d]
+\starttable[|l|l|]
+ \HL
+ \VL \bf label key \VL \bf current value \VL\SR
+ \HL
+ \VL \ShowLabelText \v!sunday \VL\FR
+ \VL \ShowLabelText \v!monday \VL\MR
+ \VL \ShowLabelText \v!tuesday \VL\MR
+ \VL \ShowLabelText \v!wednesday \VL\MR
+ \VL \ShowLabelText \v!thursday \VL\MR
+ \VL \ShowLabelText \v!friday \VL\MR
+ \VL \ShowLabelText \v!saturday \VL\LR
+ \HL
+\stoptable
+\stopbuffer
+
+\gdef\ShowTextsValues[#1][#2]%
+ {\vbox\bgroup
+ \language[#1]%
+ \setbox\scratchbox\hbox to \hsize{\hss\bfb#2 language defaults\hss}
+ \dp\scratchbox\zeropoint
+ \box\scratchbox
+ \vskip1em
+ \hrule
+ \vskip2em
+ \halign
+ {\hss##\hss&##\hskip1em&\hss##\hss\cr
+ $\vcenter{\getbuffer[lang-a]}$&&$\vcenter{\getbuffer[lang-b]}$\cr
+ \noalign{\vskip1em}
+ $\vcenter{\getbuffer[lang-c]}$&&$\vcenter{\getbuffer[lang-d]}$\cr}%
+ \egroup}
+
+\gdef\ShowLanguageValues[#1][#2]#3#4%
+ {\hbox to \hsize
+ {\hss
+ \vbox
+ \bgroup
+ \language[#1]%
+ \let\normalbar=|
+ \starttable[||||]
+ \HL
+ \VL \THREE{\bf subsentence symbol and quotes} \VL\SR
+ \HL
+ \VL \quotation{#3 #4} \VL \quote{#2} \VL \let|=\normalbar |<||<|#3|>|#4|>| \VL\FR
+ \VL \quotation{#3 #4} \VL \quote{#2} \VL |<||<|#3|>|#4|>| \VL\LR
+ \HL
+ \stoptable
+ \egroup
+ \hss}}
+
+\gdef\doShowAllLanguageValues[#1][#2]#3#4%
+ {\vbox
+ {\ShowTextsValues[#1][#2]
+ \vskip2em
+ \ShowLanguageValues[#1][#2]{#3}{#4}}
+ \protect
+ \page}
+
+\gdef\ShowAllLanguageValues
+ {\page
+ \unprotect
+ \dodoubleargument\doShowAllLanguageValues}
+
+\protect
+
+%D Command references:
+
+\usemodule[int-load] \loadsetups
+
+\unprotect
+
+\def\showsetup#1%
+ {{\def\y##1{\writestatus{setups}{warning: remove y! from #1}}%
+ \setup{#1}}}
+
+\setupframedtexts
+ [setuptext]
+ [\c!background=\v!screen,
+ \c!frame=\v!off]
+
+\protect \endinput
diff --git a/tex/context/base/s-mod-01.tex b/tex/context/base/s-mod-01.mkii
index 4454986ce..64b533d03 100644
--- a/tex/context/base/s-mod-01.tex
+++ b/tex/context/base/s-mod-01.mkii
@@ -37,9 +37,7 @@
[\v!big]
\setuptolerance
- [\v!tolerant]
-
-\emergencystretch=5em
+ [\v!verytolerant,\v!!stretch]
\setuplayout
[\c!backspace=3.5cm,
diff --git a/tex/context/base/s-mod-01.mkiv b/tex/context/base/s-mod-01.mkiv
new file mode 100644
index 000000000..fe42b832f
--- /dev/null
+++ b/tex/context/base/s-mod-01.mkiv
@@ -0,0 +1,146 @@
+%D \module
+%D [ file=s-mod-01,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Documentation Paper Environment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module looks like crap, is not documented, will
+%D change, and used to be called modu-*.tex.
+
+% now split in mkii/mkiv so we will cleanup
+
+\usemodule[mod-00,abr-01]
+
+\dontcomplain
+
+\unprotect
+
+\setupbodyfont
+ [10pt]
+
+\definetypeface [narrowtt] [tt] [mono] [modern-cond] [default]
+
+\setuptyping[\v!typing][\c!style=\narrowtt]
+\setuptype [\v!type] [\c!style=\narrowtt]
+
+\mainlanguage
+ [en]
+
+\setupwhitespace
+ [\v!big]
+
+\setuptolerance
+ [\v!verytolerant,\v!!stretch]
+
+\setuplayout
+ [\c!backspace=3.5cm,
+ \c!leftmargin=1.75cm,
+ \c!rightmargin=0cm,
+ \c!margindistance=.5cm,
+ \c!leftedgedistance=.25cm,
+ \c!rightedgedistance=.5cm,
+ \c!edge=1.5cm,
+ \c!width=15.55333cm, % 13.998cm at 9pt => 15.55333 at 10pt
+ \c!topspace=2cm,
+ \c!header=1.25cm,
+ \c!footer=1.25cm,
+ \c!height=middle,
+ \c!style=\ss]
+
+\setupsetup
+ [\c!reference=1] % mkiv?
+
+\startnotmode[single]
+
+ \setuppagenumbering
+ [\c!alternative={\v!doublesided,\v!singlesided}]
+
+\stopnotmode
+
+\setuppagenumbering
+ [\c!location=]
+
+\setupfootertexts
+ [\v!edge]
+ [][\v!pagenumber]
+
+\startmode[single]
+
+ \setupfootertexts
+ [\v!margin]
+ [\filename{\Modulefile}][]
+
+\stopmode
+
+\startnotmode[single]
+
+ \setupfootertexts
+ [\v!margin]
+ [\filename{\Modulefile}][]
+ [\filename{\Modulefile}][]
+
+\stopnotmode
+
+\setupfootertexts
+ [\v!text]
+ [\CONTEXT]
+ [\Moduletitle]
+
+\setupheadertexts
+ [\v!text]
+ []
+ [\Modulesubtitle]
+
+\setupinmargin
+ [\c!location=\v!left]
+
+\setupheads
+ [\c!alternative=\v!inmargin]
+
+\setuphead
+ [\v!chapter]
+ [\c!style=\ssc,
+ \c!page=\v!right,
+ \c!header=\v!empty]
+
+\setuphead
+ [\v!section]
+ [\c!style=\ssb,
+ \c!page=\v!right]
+
+\setuplist
+ [\v!chapter]
+ [\c!style=\v!bold,
+ \c!after=\blank]
+
+\setupcombinedlist
+ [\v!content]
+ [\c!width=3em,
+ \c!aligntitle=\v!yes]
+
+\setupregister
+ [\v!index]
+ [\c!balance=\v!yes,
+ \c!indicator=\v!no]
+
+\startmode[nocolor]
+
+ \setupcolors
+ [\c!conversion=\v!always]
+
+\stopmode
+
+\setupinteraction
+ [\c!state=\v!start,
+ \c!color=,
+ \c!contrastcolor=,
+ \c!style=]
+
+\protect \endinput
diff --git a/tex/context/base/s-mod-02.tex b/tex/context/base/s-mod-02.mkii
index fac5c23e6..fac5c23e6 100644
--- a/tex/context/base/s-mod-02.tex
+++ b/tex/context/base/s-mod-02.mkii
diff --git a/tex/context/base/s-mod-02.mkiv b/tex/context/base/s-mod-02.mkiv
new file mode 100644
index 000000000..f62513dd3
--- /dev/null
+++ b/tex/context/base/s-mod-02.mkiv
@@ -0,0 +1,421 @@
+%D \module
+%D [ file=s-mod-02,
+%D version=very-old,
+%D title=\CONTEXT\ Style File,
+%D subtitle=Documentation Screen Environment,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+%D This module looks like crap, is not documented, will
+%D change, and used to be called modu-*.tex.
+
+% now split in mkii/mkiv so we will cleanup
+
+% Macro's
+
+\usemodule[mod-00]
+
+% todo: internationalize + setups
+
+\setuphead[paragraaf][expansion=command]
+\setuphead[section][expansion=command]
+
+\def\complexmodule[#1]% redefined
+ {\startglobal % i.v.m. \bgroup in \startdocumentation
+ \getparameters[Module][#1]
+ \stopglobal % i.v.m. \bgroup in \startdocumentation
+ %%\section{\Modulesubtitle}
+ \xdef\Temp{\Modulesubtitle}%%Modulesubtitle:\framed{BEGIN \Modulesubtitle END} :#1 !}
+ \@EA\section\@EA{\Temp}
+ \WriteLists}
+
+\def\stopmodule % redefined
+ {\page
+ \determineregistercharacteristics
+ [index]
+ [criterium=section]
+ \doifmode{*register}
+ {\pagereference
+ [index]
+ \placeregister
+ [index]
+ [balance=yes,
+ indicator=no,
+ criterium=section]}}
+
+\let\ComposeLists=\relax
+
+\newcounter\ModuleNumber
+
+\newwrite\BatchFile \openout\BatchFile=\jobname.bat
+
+\def\WriteBatchFile
+ {\doglobal\increment\ModuleNumber
+% \immediate\write\BatchFile{call modu-run \FileName\space \ModuleNumber}}
+% \immediate\write\BatchFile{texmfstart texutil --modu \FileName}}
+ \immediate\write\BatchFile{texmfstart texexec --pdf --modu --batch \FileName }}
+
+\newif\ifProcessingPublic
+
+\def\WriteLists
+ {\writetolist[FileNames] {}{\FileName}
+ \writetolist[GroupItems]{}{\GroupItem}}
+
+\def\moduletitle{}
+
+\def\TypeZeroModule#1%
+ {\section{[to be extracted: #1]}
+ {\em This module is not yet split off.}
+ \WriteLists}
+
+\def\TypeOneModule#1%
+ {\section{[to be documented: #1]}
+ {\em This module is not yet fully documented.}
+ \WriteLists}
+
+\def\TypeTwoModule#1%
+ {\ifProcessingPublic
+ \readfile{#1.ted}{}{}%
+ \WriteBatchFile
+ \else
+ \section{[not yet public: #1]}
+ {\em This module is documented but not yet public.}
+ \WriteLists
+ \fi}
+
+\def\TypeThreeModule#1%
+ {\readfile{#1.ted}{}{}%
+ \WriteBatchFile}
+
+\def\processmodule#1#2%
+ {\page
+ \bgroup
+ \def\FileName{#1}
+ \setupreferencing[prefix=#1]
+ \useexternaldocument[PaperVersion][#1][]
+ \aftersplitstring#1\at-\to\GroupItem
+ \ComposeLists
+ \ifcase#2
+ \TypeZeroModule{#1}
+ \or
+ \TypeOneModule{#1}
+ \or
+ \TypeTwoModule{#1}
+ \or
+ \TypeThreeModule{#1}
+ \fi
+ \page
+ \setupreferencing[prefix=]
+ \egroup}
+
+\def\ModuleGroup#1#2%
+ {\page
+ \let\Modulefile=\empty
+ \setupreferencing[prefix=#1]
+ \def\FileGroup{#1}
+ \writetolist[FileGroups]{}{\FileGroup}
+ \chapter[content]{#2}
+ \MakeListOfItems
+ \MakeListOfNames
+ \MakeListOfGroups
+ \placecontent[criterium=chapter,level=section]}
+
+% Layout
+
+\setupbodyfont
+ [9pt]
+
+\setuppapersize
+ [S6][S6]
+
+\setuplayout
+ [backspace=72.5pt,
+ leftmargin=50pt,
+ leftmargindistance=12.5pt,
+ rightmargin=0pt,
+ rightedge=80pt,
+ rightedgedistance=10pt,
+ leftedge=0pt,
+ width=430pt,
+ topspace=10pt,
+ header=0pt,
+ footer=30pt,
+ bottomdistance=10pt,
+ bottom=15pt,
+ height=410pt,
+ style=\ss]
+
+\setuptyping
+ [palet=colorpretty]
+
+\setupsetup
+ [reference=3]
+
+\definecolor [AchtergrondKleur] [s=.6]
+\definecolor [ButtonKleur] [r=.2,g=.2,b=.6]
+\definecolor [TekstKleur] [r=.6,g=.2,b=.2]
+
+\definecolor [colorprettyone] [r=.6,g=.0,b=.0] % red
+\definecolor [colorprettytwo] [r=.0,g=.6,b=.0] % green
+\definecolor [colorprettythree] [r=.0,g=.0,b=.6] % blue
+\definecolor [colorprettyfour] [r=.6,g=.6,b=.0] % yellow
+
+\setupinteraction
+ [state=start,
+ page=yes,
+ contrastcolor=,
+ menu=on,
+ color=]
+
+\setupbackgrounds
+ [page]
+ [background=color,
+ backgroundcolor=AchtergrondKleur,
+ offset=2.5pt] % this offset influences the menus!
+
+\setupbackgrounds
+ [text,footer]
+ [text,leftmargin]
+ [background=color,
+ backgroundcolor=white]
+
+\setupsubpagenumber
+ [way=bysection,
+ state=start]
+
+\setupinteractionbar
+ [frame=off,
+ offset=0pt,
+ height=fit]
+
+\setupwhitespace
+ [big]
+
+\setuptyping
+ [typing]
+ [option=color]
+
+\setuptyping
+ [definition]
+ [option=color]
+
+\setuptyping
+ [file]
+ [option=color]
+
+\setuppagenumbering
+ [alternative=singlesided,
+ way=bysection,
+ state=none]
+
+\setupinmargin
+ [location=left]
+
+\setupheads
+ [alternative=inmargin]
+
+\setuphead
+ [chapter]
+ [style=\ssc,
+ page=right]
+
+\setuphead
+ [section]
+ [style=\ssb,
+ page=right]
+
+\setuplist
+ [chapter]
+ [style=bold,
+ after=\blank]
+
+\setupcontent
+ [width=2em]
+
+\setupindex
+ [balance=yes,
+ indicator=no]
+
+\setupcolors
+ [state=start]
+
+\def\TitelBlad#1%
+ {\startstandardmakeup
+ \definefont[GrootFont] [SansBold at 72pt]
+ \definefont[MiddelFont][Sans at 32pt]
+ \definefont[KleinFont] [Sans at 24pt]
+ \startcolor[AchtergrondKleur]
+ \vskip12pt
+ \midaligned{\GrootFont\setstrut\strut Con\TeX t}
+ \vskip24pt
+ \midaligned{\MiddelFont\setstrut\strut #1}
+ \vskip24pt
+ \midaligned{\KleinFont\setstrut\strut Hans Hagen}
+ \vfilll
+ \midaligned{\KleinFont\setstrut\strut PRAGMA ADE}
+ \vskip24pt
+ \midaligned{\KleinFont\setstrut\strut www.pragma-ade.com --- \currentdate}
+ \vskip12pt
+ \stopcolor
+ \stopstandardmakeup}
+
+\def\ColofonBlad
+ {\startmode[atpragma]
+ \page
+ \bgroup
+ \def\PragmaHoogte {\makeupheight}
+ \def\PragmaBreedte{\textwidth}
+ \def\PragmaKopwit {\topspace}
+ \def\PragmaRugwit {\backspace}
+ \def\PragmaMarge {0pt}
+ \PragmaLijnentrue
+ \PlaatsPragmaLogo[ADE]
+ \vfill
+ todo: colofon
+ \startnarrower[3*middle]
+ This is the official documentation of \CONTEXT\ version
+ \referraldate, a \TEX\ macropackage developed by J.~Hagen
+ \& A.F.~Otten, who both hold the copyrights.
+ \stopnarrower
+ \vfill
+ \page
+ \egroup
+ \stopmode}
+
+\def\ColofonBlad
+ {}
+
+\newbox\ListOfItems
+\newbox\ListOfGroups
+\newbox\ListOfNames
+
+\definelist[FileNames] \def\FileName {}
+\definelist[FileGroups] \def\FileGroup {}
+\definelist[GroupItems] \def\GroupItem {}
+
+\setuplist
+ [FileNames,FileGroups,FileGroups]
+ [expansion=yes,
+ pagenumber=no,
+ style=\ss\bf]
+
+\setuplist
+ [FileNames]
+ [command=\FileNameEntry,
+ after=\endgraf,
+ alternative=none] % horizontal
+
+\setuplist
+ [FileGroups]
+ [command=\FileGroupEntry,
+ after=\hss,
+ alternative=horizontal]
+
+\def\FileNameEntry#1#2#3%
+ {\strut\hbox{#2}\endgraf}
+
+\def\FileGroupEntry#1#2#3%
+ {\strut\hbox{#2}\endgraf}
+
+\def\MakeListOfItems
+ {\setbox\ListOfItems=\vbox
+ {\ss\bf
+ \placelist[GroupItems][color=ButtonKleur,contrastcolor=white,criterium=chapter]}}
+
+\def\MakeListOfNames
+ {\setbox\ListOfNames=\vbox
+ {\hsize\rightedgewidth
+ \ss\bf\setupinterlinespace
+ \startsimplecolumns[distance=10pt]
+ \placelist[FileNames][color=ButtonKleur,contrastcolor=white,criterium=chapter]
+ \stopsimplecolumns}}
+
+\def\MakeListOfGroups
+ {\setbox\ListOfGroups=\hbox to \textwidth
+ {\ss\bf
+ \setupinteraction[color=ButtonKleur]%
+ \placelist[FileGroups][color=ButtonKleur,contrastcolor=white,criterium=all]\unskip\unskip}}
+
+\setbox\ListOfGroups=\hbox{}
+
+%\setupfootertexts
+% [rand]
+% []
+% [{\interactiebalk[variant=g]}]
+
+\setupinteractionmenu
+ [right,bottom]
+ [state=start,
+ frame=off,
+ color=AchtergrondKleur,
+ contrastcolor=white,
+ style=\ss\bf,
+ height=15pt,
+ offset=0pt,
+ inbetween=\vskip5pt,
+ background=color,
+ backgroundcolor=ButtonKleur]
+
+\startinteractionmenu[right]
+ \boxofsize \vbox \textheight \footerdistance \footerheight 5pt
+ \bgroup
+ \copy\ListOfNames
+ \vfill
+ \but [\FileGroup:content] local contents \\
+ \but [\FileName:index] local register \\
+ \but [PaperVersion::begin] paper version \\
+ \but [content] main contents \\
+ \but [index] main register \\
+ \but [PreviousJump] previous jump \\
+ \but [CloseDocument] close document \\
+ \unskip
+ \egroup
+\stopinteractionmenu
+
+\startinteractionmenu[bottom]
+ \unhcopy\ListOfGroups
+\stopinteractionmenu
+
+\def\placemoduleregister
+ {\startbackmatter
+ \setupsubpagenumber[reset]
+ \title[-:index]{Register}
+ \placeregister[index]
+ \stopbackmatter}
+
+\def\placemodulecontent
+ {\startfrontmatter
+ \title[-:content]{Contents}
+ \setupinteractionbar[state=stop]
+ \placecontent[criterium=text,level=chapter]
+ \stopfrontmatter}
+
+\setupcontent
+ [pagenumber=no,
+ level=chapter,
+ interaction=all,
+ style=,
+ before=,
+ after=]
+
+\setupfootertexts
+ [margin]
+ [\tt\Modulefile]
+ []
+
+\setupfootertexts
+ [text]
+ [chapter][chapter]
+
+\setupindex
+ [symbol=1]
+
+\setuptolerance
+ [verytolerant]
+
+\endinput
diff --git a/tex/context/base/type-otf.mkiv b/tex/context/base/type-otf.mkiv
index 4d6f00bfe..c9b4857bb 100644
--- a/tex/context/base/type-otf.mkiv
+++ b/tex/context/base/type-otf.mkiv
@@ -1712,6 +1712,7 @@
\definefontsynonym [Libertine-Italic] [\s!file:fxlri]
\definefontsynonym [Libertine-Bold] [\s!file:fxlb]
\definefontsynonym [Libertine-BoldItalic] [\s!file:fxlbi]
+ \definefontsynonym [Libertine-SmallCaps] [\s!file:fxlr] [\s!features=\s!smallcaps]
\stoptypescript
\starttypescript [serif] [libertine] [name]
diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua
index 890e2bac4..a182687cd 100644
--- a/tex/generic/context/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 12/22/10 20:19:01
+-- merge date : 12/31/10 08:59:52
do -- begin closure to overcome local limits and interference
diff --git a/tex/generic/context/luatex-mplib.lua b/tex/generic/context/luatex-mplib.lua
new file mode 100644
index 000000000..c6628acb3
--- /dev/null
+++ b/tex/generic/context/luatex-mplib.lua
@@ -0,0 +1,491 @@
+if not modules then modules = { } end modules ['luatex-mplib'] = {
+ version = 1.001,
+ comment = "companion to luatex-mplib.tex",
+ author = "Hans Hagen & Taco Hoekwater",
+ copyright = "ConTeXt Development Team",
+ license = "public domain",
+}
+
+--[[ldx--
+<p>This module is a stripped down version of libraries that are used
+by <l n='context'/>. It can be used in other macro packages and/or
+serve as an example. Embedding in a macro package is upto others and
+normally boils down to inputting <t>supp-mpl.tex</t>.</p>
+--ldx]]--
+
+if metapost and metapost.version then
+
+ --[[ldx--
+ <p>Let's silently quit and make sure that no one loads it
+ manually in <l n='context'/>.</p>
+ --ldx]]--
+
+else
+
+ local format, concat, abs, match = string.format, table.concat, math.abs, string.match
+
+ local mplib = require ('mplib')
+ local kpse = require ('kpse')
+
+ --[[ldx--
+ <p>We create a namespace and some variables to it. If a namespace is
+ already defined it wil not be initialized. This permits hooking
+ in code beforehand.</p>
+
+ <p>We don't make a format automatically. After all, distributions
+ might have their own preferences and normally a format (mem) file will
+ have some special place in the <l n='tex'/> tree. Also, there can already
+ be format files, different memort settings and other nasty pitfalls that
+ we don't want to interfere with. If you want, you can define a function
+ <t>metapost.make(name,mem_name) that does the job.</t></p>
+ --ldx]]--
+
+ metapost = metapost or { }
+ metapost.version = 1.00
+ metapost.showlog = metapost.showlog or false
+ metapost.lastlog = ""
+
+ --[[ldx--
+ <p>A few helpers, taken from <t>l-file.lua</t>.</p>
+ --ldx]]--
+
+ local file = file or { }
+
+ function file.replacesuffix(filename, suffix)
+ return (string.gsub(filename,"%.[%a%d]+$","")) .. "." .. suffix
+ end
+
+ function file.stripsuffix(filename)
+ return (string.gsub(filename,"%.[%a%d]+$",""))
+ end
+
+ --[[ldx--
+ <p>We use the <l n='kpse'/> library unless a finder is already
+ defined.</p>
+ --ldx]]--
+
+ local mpkpse = kpse.new("luatex","mpost")
+
+ metapost.finder = metapost.finder or function(name, mode, ftype)
+ if mode == "w" then
+ return name
+ else
+ return mpkpse:find_file(name,ftype)
+ end
+ end
+
+ --[[ldx--
+ <p>You can use your own reported if needed, as long as it handles multiple
+ arguments and formatted strings.</p>
+ --ldx]]--
+
+ metapost.report = metapost.report or function(...)
+ texio.write(format("<mplib: %s>",format(...)))
+ end
+
+ --[[ldx--
+ <p>The rest of this module is not documented. More info can be found in the
+ <l n='luatex'/> manual, articles in user group journals and the files that
+ ship with <l n='context'/>.</p>
+ --ldx]]--
+
+ function metapost.resetlastlog()
+ metapost.lastlog = ""
+ end
+
+ local mplibone = tonumber(mplib.version()) <= 1.50
+
+ if mplibone then
+
+ metapost.make = metapost.make or function(name,mem_name,dump)
+ local t = os.clock()
+ local mpx = mplib.new {
+ ini_version = true,
+ find_file = metapost.finder,
+ job_name = file.stripsuffix(name)
+ }
+ mpx:execute(string.format("input %s ;",name))
+ if dump then
+ mpx:execute("dump ;")
+ metapost.report("format %s made and dumped for %s in %0.3f seconds",mem_name,name,os.clock()-t)
+ else
+ metapost.report("%s read in %0.3f seconds",name,os.clock()-t)
+ end
+ return mpx
+ end
+
+ function metapost.load(name)
+ local mem_name = file.replacesuffix(name,"mem")
+ local mpx = mplib.new {
+ ini_version = false,
+ mem_name = mem_name,
+ find_file = metapost.finder
+ }
+ if not mpx and type(metapost.make) == "function" then
+ -- when i have time i'll locate the format and dump
+ mpx = metapost.make(name,mem_name)
+ end
+ if mpx then
+ metapost.report("using format %s",mem_name,false)
+ return mpx, nil
+ else
+ return nil, { status = 99, error = "out of memory or invalid format" }
+ end
+ end
+
+ else
+
+ local preamble = [[
+ boolean mplib ; mplib := true ;
+ let dump = endinput ;
+ input %s ;
+ ]]
+
+ metapost.make = metapost.make or function()
+ end
+
+ function metapost.load(name)
+ local mpx = mplib.new {
+ ini_version = true,
+ find_file = metapost.finder,
+ }
+ local result
+ if not mpx then
+ result = { status = 99, error = "out of memory"}
+ else
+ result = mpx:execute(format(preamble, file.replacesuffix(name,"mp")))
+ end
+ metapost.reporterror(result)
+ return mpx, result
+ end
+
+ end
+
+ function metapost.unload(mpx)
+ if mpx then
+ mpx:finish()
+ end
+ end
+
+ function metapost.reporterror(result)
+ if not result then
+ metapost.report("mp error: no result object returned")
+ elseif result.status > 0 then
+ local t, e, l = result.term, result.error, result.log
+ if t then
+ metapost.report("mp terminal: %s",t)
+ end
+ if e then
+ metapost.report("mp error: %s", e)
+ end
+ if not t and not e and l then
+ metapost.lastlog = metapost.lastlog .. "\n " .. l
+ metapost.report("mp log: %s",l)
+ else
+ metapost.report("mp error: unknown, no error, terminal or log messages")
+ end
+ else
+ return false
+ end
+ return true
+ end
+
+ function metapost.process(mpx, data)
+ local converted, result = false, {}
+ mpx = metapost.load(mpx)
+ if mpx and data then
+ local result = mpx:execute(data)
+ if not result then
+ metapost.report("mp error: no result object returned")
+ elseif result.status > 0 then
+ metapost.report("mp error: %s",(result.term or "no-term") .. "\n" .. (result.error or "no-error"))
+ elseif metapost.showlog then
+ metapost.lastlog = metapost.lastlog .. "\n" .. result.term
+ metapost.report("mp info: %s",result.term or "no-term")
+ elseif result.fig then
+ converted = metapost.convert(result)
+ else
+ metapost.report("mp error: unknown error, maybe no beginfig/endfig")
+ end
+ else
+ metapost.report("mp error: mem file not found")
+ end
+ return converted, result
+ end
+
+ local function getobjects(result,figure,f)
+ return figure:objects()
+ end
+
+ function metapost.convert(result, flusher)
+ metapost.flush(result, flusher)
+ return true -- done
+ end
+
+ --[[ldx--
+ <p>We removed some message and tracing code. We might even remove the flusher</p>
+ --ldx]]--
+
+ local function pdf_startfigure(n,llx,lly,urx,ury)
+ tex.sprint(format("\\startMPLIBtoPDF{%s}{%s}{%s}{%s}",llx,lly,urx,ury))
+ end
+
+ local function pdf_stopfigure()
+ tex.sprint("\\stopMPLIBtoPDF")
+ end
+
+ function pdf_literalcode(fmt,...) -- table
+ tex.sprint(format("\\MPLIBtoPDF{%s}",format(fmt,...)))
+ end
+
+ function pdf_textfigure(font,size,text,width,height,depth)
+ text = text:gsub(".","\\hbox{%1}") -- kerning happens in metapost
+ tex.sprint(format("\\MPLIBtextext{%s}{%s}{%s}{%s}{%s}",font,size,text,0,-( 7200/ 7227)/65536*depth))
+ end
+
+ local bend_tolerance = 131/65536
+
+ local rx, sx, sy, ry, tx, ty, divider = 1, 0, 0, 1, 0, 0, 1
+
+ local function pen_characteristics(object)
+ local t = mplib.pen_info(object)
+ rx, ry, sx, sy, tx, ty = t.rx, t.ry, t.sx, t.sy, t.tx, t.ty
+ divider = sx*sy - rx*ry
+ return not (sx==1 and rx==0 and ry==0 and sy==1 and tx==0 and ty==0), t.width
+ end
+
+ local function concat(px, py) -- no tx, ty here
+ return (sy*px-ry*py)/divider,(sx*py-rx*px)/divider
+ end
+
+ local function curved(ith,pth)
+ local d = pth.left_x - ith.right_x
+ if abs(ith.right_x - ith.x_coord - d) <= bend_tolerance and abs(pth.x_coord - pth.left_x - d) <= bend_tolerance then
+ d = pth.left_y - ith.right_y
+ if abs(ith.right_y - ith.y_coord - d) <= bend_tolerance and abs(pth.y_coord - pth.left_y - d) <= bend_tolerance then
+ return false
+ end
+ end
+ return true
+ end
+
+ local function flushnormalpath(path,open)
+ local pth, ith
+ for i=1,#path do
+ pth = path[i]
+ if not ith then
+ pdf_literalcode("%f %f m",pth.x_coord,pth.y_coord)
+ elseif curved(ith,pth) then
+ pdf_literalcode("%f %f %f %f %f %f c",ith.right_x,ith.right_y,pth.left_x,pth.left_y,pth.x_coord,pth.y_coord)
+ else
+ pdf_literalcode("%f %f l",pth.x_coord,pth.y_coord)
+ end
+ ith = pth
+ end
+ if not open then
+ local one = path[1]
+ if curved(pth,one) then
+ pdf_literalcode("%f %f %f %f %f %f c",pth.right_x,pth.right_y,one.left_x,one.left_y,one.x_coord,one.y_coord )
+ else
+ pdf_literalcode("%f %f l",one.x_coord,one.y_coord)
+ end
+ elseif #path == 1 then
+ -- special case .. draw point
+ local one = path[1]
+ pdf_literalcode("%f %f l",one.x_coord,one.y_coord)
+ end
+ return t
+ end
+
+ local function flushconcatpath(path,open)
+ pdf_literalcode("%f %f %f %f %f %f cm", sx, rx, ry, sy, tx ,ty)
+ local pth, ith
+ for i=1,#path do
+ pth = path[i]
+ if not ith then
+ pdf_literalcode("%f %f m",concat(pth.x_coord,pth.y_coord))
+ elseif curved(ith,pth) then
+ local a, b = concat(ith.right_x,ith.right_y)
+ local c, d = concat(pth.left_x,pth.left_y)
+ pdf_literalcode("%f %f %f %f %f %f c",a,b,c,d,concat(pth.x_coord, pth.y_coord))
+ else
+ pdf_literalcode("%f %f l",concat(pth.x_coord, pth.y_coord))
+ end
+ ith = pth
+ end
+ if not open then
+ local one = path[1]
+ if curved(pth,one) then
+ local a, b = concat(pth.right_x,pth.right_y)
+ local c, d = concat(one.left_x,one.left_y)
+ pdf_literalcode("%f %f %f %f %f %f c",a,b,c,d,concat(one.x_coord, one.y_coord))
+ else
+ pdf_literalcode("%f %f l",concat(one.x_coord,one.y_coord))
+ end
+ elseif #path == 1 then
+ -- special case .. draw point
+ local one = path[1]
+ pdf_literalcode("%f %f l",concat(one.x_coord,one.y_coord))
+ end
+ return t
+ end
+
+ --[[ldx--
+ <p>Support for specials has been removed.</p>
+ --ldx]]--
+
+ function metapost.flush(result,flusher)
+ if result then
+ local figures = result.fig
+ if figures then
+ for f=1, #figures do
+ metapost.report("flushing figure %s",f)
+ local figure = figures[f]
+ local objects = getobjects(result,figure,f)
+ local fignum = tonumber(match(figure:filename(),"([%d]+)$") or figure:charcode() or 0)
+ 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
+ if urx < llx then
+ -- invalid
+ pdf_startfigure(fignum,0,0,0,0)
+ pdf_stopfigure()
+ else
+ pdf_startfigure(fignum,llx,lly,urx,ury)
+ pdf_literalcode("q")
+ if objects then
+ 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
+ pdf_literalcode("q")
+ flushnormalpath(object.path,t,false)
+ pdf_literalcode("W n")
+ elseif objecttype == "stop_clip" then
+ pdf_literalcode("Q")
+ miterlimit, linecap, linejoin, dashed = -1, -1, -1, false
+ elseif objecttype == "special" then
+ -- not supported
+ elseif objecttype == "text" then
+ local ot = object.transform -- 3,4,5,6,1,2
+ pdf_literalcode("q %f %f %f %f %f %f cm",ot[3],ot[4],ot[5],ot[6],ot[1],ot[2])
+ pdf_textfigure(object.font,object.dsize,object.text,object.width,object.height,object.depth)
+ pdf_literalcode("Q")
+ else
+ local cs = object.color
+ if cs and #cs > 0 then
+ pdf_literalcode(metapost.colorconverter(cs))
+ end
+ local ml = object.miterlimit
+ if ml and ml ~= miterlimit then
+ miterlimit = ml
+ pdf_literalcode("%f M",ml)
+ end
+ local lj = object.linejoin
+ if lj and lj ~= linejoin then
+ linejoin = lj
+ pdf_literalcode("%i j",lj)
+ end
+ local lc = object.linecap
+ if lc and lc ~= linecap then
+ linecap = lc
+ pdf_literalcode("%i J",lc)
+ end
+ local dl = object.dash
+ if dl then
+ local d = format("[%s] %i d",concat(dl.dashes or {}," "),dl.offset)
+ if d ~= dashed then
+ dashed = d
+ pdf_literalcode(dashed)
+ end
+ elseif dashed then
+ pdf_literalcode("[] 0 d")
+ dashed = false
+ end
+ local path = object.path
+ local transformed, penwidth = false, 1
+ local open = path and path[1].left_type and path[#path].right_type
+ local pen = object.pen
+ if pen then
+ if pen.type == 'elliptical' then
+ transformed, penwidth = pen_characteristics(object) -- boolean, value
+ pdf_literalcode("%f w",penwidth)
+ if objecttype == 'fill' then
+ objecttype = 'both'
+ end
+ else -- calculated by mplib itself
+ objecttype = 'fill'
+ end
+ end
+ if transformed then
+ pdf_literalcode("q")
+ end
+ if path then
+ if transformed then
+ flushconcatpath(path,open)
+ else
+ flushnormalpath(path,open)
+ end
+ if objecttype == "fill" then
+ pdf_literalcode("h f")
+ elseif objecttype == "outline" then
+ pdf_literalcode((open and "S") or "h S")
+ elseif objecttype == "both" then
+ pdf_literalcode("h B")
+ end
+ end
+ if transformed then
+ pdf_literalcode("Q")
+ end
+ local path = object.htap
+ if path then
+ if transformed then
+ pdf_literalcode("q")
+ end
+ if transformed then
+ flushconcatpath(path,open)
+ else
+ flushnormalpath(path,open)
+ end
+ if objecttype == "fill" then
+ pdf_literalcode("h f")
+ elseif objecttype == "outline" then
+ pdf_literalcode((open and "S") or "h S")
+ elseif objecttype == "both" then
+ pdf_literalcode("h B")
+ end
+ if transformed then
+ pdf_literalcode("Q")
+ end
+ end
+ if cr then
+ pdf_literalcode(cr)
+ end
+ end
+ end
+ end
+ pdf_literalcode("Q")
+ pdf_stopfigure()
+ end
+ end
+ end
+ end
+ end
+
+ function metapost.colorconverter(cr)
+ local n = #cr
+ if n == 4 then
+ local c, m, y, k = cr[1], cr[2], cr[3], cr[4]
+ return format("%.3f %.3f %.3f %.3f k %.3f %.3f %.3f %.3f K",c,m,y,k,c,m,y,k), "0 g 0 G"
+ elseif n == 3 then
+ local r, g, b = cr[1], cr[2], cr[3]
+ return format("%.3f %.3f %.3f rg %.3f %.3f %.3f RG",r,g,b,r,g,b), "0 g 0 G"
+ else
+ local s = cr[1]
+ return format("%.3f g %.3f G",s,s), "0 g 0 G"
+ end
+ end
+
+end