From 16a05ab43b53feac7c21bceccc2886857e9822a8 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Sat, 30 Jun 2012 12:32:00 +0200 Subject: beta 2012.06.30 12:32 --- tex/context/base/attr-lay.lua | 8 +- tex/context/base/buff-ver.mkiv | 5 + tex/context/base/cont-log.mkiv | 8 + tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4143 -> 4146 bytes tex/context/base/context-version.png | Bin 106299 -> 106156 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 6 +- tex/context/base/core-mis.mkiv | 738 --------------------- tex/context/base/core-var.mkiv | 11 + tex/context/base/enco-ini.mkiv | 92 +-- tex/context/base/font-aux.mkvi | 81 +-- tex/context/base/lang-lab.lua | 35 +- tex/context/base/lang-lab.mkiv | 38 +- tex/context/base/lang-mis.mkiv | 7 + tex/context/base/meta-grd.mkiv | 116 ++++ tex/context/base/mult-aux.mkiv | 6 + tex/context/base/mult-def.mkiv | 2 + tex/context/base/mult-low.lua | 5 +- tex/context/base/mult-sys.mkiv | 3 - tex/context/base/node-fin.lua | 26 +- tex/context/base/node-typ.lua | 4 +- tex/context/base/pack-pos.mkiv | 53 +- tex/context/base/status-files.pdf | Bin 24485 -> 24466 bytes tex/context/base/status-lua.pdf | Bin 182541 -> 182510 bytes tex/context/base/status-mkiv.lua | 27 +- tex/context/base/status-mkiv.tex | 6 +- tex/context/base/strc-des.mkvi | 19 + tex/context/base/syst-ini.mkiv | 3 + tex/context/base/tabl-mis.mkiv | 288 ++++++++ tex/context/base/tabl-ntb.mkiv | 2 +- tex/context/base/tabl-tbl.mkiv | 24 +- tex/context/base/trac-vis.lua | 96 ++- tex/context/base/trac-vis.mkiv | 18 +- tex/context/base/typo-itm.mkiv | 273 ++++++++ tex/context/base/typo-txt.mkvi | 174 ++++- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 38 files changed, 1182 insertions(+), 1000 deletions(-) delete mode 100644 tex/context/base/core-mis.mkiv create mode 100644 tex/context/base/meta-grd.mkiv create mode 100644 tex/context/base/tabl-mis.mkiv create mode 100644 tex/context/base/typo-itm.mkiv (limited to 'tex') diff --git a/tex/context/base/attr-lay.lua b/tex/context/base/attr-lay.lua index e154ee90d..bb5cce4e2 100644 --- a/tex/context/base/attr-lay.lua +++ b/tex/context/base/attr-lay.lua @@ -57,6 +57,8 @@ local texgetattribute = tex.getattribute local texsettokenlist = tex.settoks local unsetvalue = attributes.unsetvalue +local nodepool = nodes.pool + storage.register("attributes/viewerlayers/registered", viewerlayers.registered, "attributes.viewerlayers.registered") storage.register("attributes/viewerlayers/values", viewerlayers.values, "attributes.viewerlayers.values") storage.register("attributes/viewerlayers/scopes", viewerlayers.scopes, "attributes.viewerlayers.scopes") @@ -115,7 +117,7 @@ function layerstacker.start(s,t,first,last) -- move to lpdf-ren.lua end r = concat(r," ") -- print("start",r) - return nodes.pool.pdfliteral(r) + return nodepool.pdfliteral(r) end function layerstacker.stop(s,t,first,last) -- move to lpdf-ren.lua @@ -125,7 +127,7 @@ function layerstacker.stop(s,t,first,last) -- move to lpdf-ren.lua end r = concat(r," ") -- print("stop",r) - return nodes.pool.pdfliteral(r) + return nodepool.pdfliteral(r) end function layerstacker.change(s,t1,first1,last1,t2,first2,last2) -- move to lpdf-ren.lua @@ -138,7 +140,7 @@ function layerstacker.change(s,t1,first1,last1,t2,first2,last2) -- move to lpdf- end r = concat(r," ") -- print("change",r) - return nodes.pool.pdfliteral(r) + return nodepool.pdfliteral(r) end local function initializer(...) diff --git a/tex/context/base/buff-ver.mkiv b/tex/context/base/buff-ver.mkiv index 3728bd16b..d8fbe31b4 100644 --- a/tex/context/base/buff-ver.mkiv +++ b/tex/context/base/buff-ver.mkiv @@ -836,4 +836,9 @@ % \usevisualizerstyleandcolor\c!style\c!color % \let\next} +\appendtoks + \def\type#1{\letterbackslash\checkedstrippedcsname#1}% or maybe detokenize + \def\tex #1{\letterbackslash#1}% +\to \simplifiedcommands + \protect \endinput diff --git a/tex/context/base/cont-log.mkiv b/tex/context/base/cont-log.mkiv index 67647920d..5baa05bee 100644 --- a/tex/context/base/cont-log.mkiv +++ b/tex/context/base/cont-log.mkiv @@ -270,4 +270,12 @@ \unexpanded\def\MPII{MpII} \unexpanded\def\MPIV{MpIV} +\appendtoks + \def\ConTeXt {ConTeXt}% + \def\MetaPost{MetaPost}% + \def\MetaFont{MetaFont}% + \def\MetaFun {MetaFun}% + \def\TeX {TeX}% +\to \simplifiedcommands + \protect \endinput diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii index 89c34ce86..6cb0f0bdc 100644 --- a/tex/context/base/cont-new.mkii +++ b/tex/context/base/cont-new.mkii @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.06.28 10:00} +\newcontextversion{2012.06.30 12:32} %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/cont-new.mkiv b/tex/context/base/cont-new.mkiv index c607f8f77..442b42222 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2012.06.28 10:00} +\newcontextversion{2012.06.30 12:32} %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-version.pdf b/tex/context/base/context-version.pdf index 591eeabaf..b0e91f6fa 100644 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 07bec5836..2a2f8a374 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png differ diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii index 97cfe223e..c547b109d 100644 --- a/tex/context/base/context.mkii +++ b/tex/context/base/context.mkii @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2012.06.28 10:00} +\edef\contextversion{2012.06.30 12:32} %D For those who want to use this: diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 61e86bba4..bcaa34449 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -23,7 +23,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2012.06.28 10:00} +\edef\contextversion{2012.06.30 12:32} %D For those who want to use this: @@ -287,6 +287,7 @@ \loadmarkfile{page-par} \loadmarkfile{typo-pag} \loadmarkfile{typo-mar} +\loadmarkfile{typo-itm} \loadmarkfile{buff-ini} \loadmarkfile{buff-ver} @@ -324,6 +325,7 @@ \loadmarkfile{tabl-ltb} \loadmarkfile{tabl-tsp} \loadmkvifile{tabl-xtb} +\loadmarkfile{tabl-mis} \loadmarkfile{java-ini} @@ -384,6 +386,7 @@ \loadmarkfile{meta-tex} \loadmarkfile{meta-fun} \loadmarkfile{meta-pag} +\loadmarkfile{meta-grd} \loadmarkfile{page-mrk} % depends on mp @@ -427,7 +430,6 @@ \loadmkvifile{strc-not} \loadmkvifile{strc-lnt} -\loadmarkfile{core-mis} \loadmarkfile{pack-com} \loadmarkfile{typo-del} diff --git a/tex/context/base/core-mis.mkiv b/tex/context/base/core-mis.mkiv deleted file mode 100644 index 030eef6a7..000000000 --- a/tex/context/base/core-mis.mkiv +++ /dev/null @@ -1,738 +0,0 @@ -%D \module -%D [ file=core-mis, -%D version=1998.01.29, -%D title=\CONTEXT\ Core Macros, -%D subtitle=Miscelaneous, -%D author=Hans Hagen, -%D date=\currentdate, -%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] -%C -%C This module is part of the \CONTEXT\ macro||package and is -%C therefore copyrighted by \PRAGMA. See mreadme.pdf for -%C details. - -\writestatus{loading}{ConTeXt Core Macros / Misc Commands} - -% needs to be redone - -\unprotect - -%D Sometimes (for instance in bookmarks) we need to simplify macro -%D behaviour, so here is the hook. - -\ifx\simplifiedcommands\undefined \newtoks\simplifiedcommands \fi - -\def\simplifycommands{\the\simplifiedcommands} - -%D A possibly growing list: - -%appendtoks \def\executesynonym#1#2#3#4{#3}\to\simplifiedcommands -%appendtoks \def\executesort#1#2#3{#3}\to\simplifiedcommands - -\appendtoks \def\ { }\to\simplifiedcommands -\appendtoks \def\type#1{\letterbackslash\checkedstrippedcsname#1}\to\simplifiedcommands -\appendtoks \def\tex#1{\letterbackslash#1}\to\simplifiedcommands -\appendtoks \def\TeX{TeX}\to\simplifiedcommands -\appendtoks \def\ConTeXt{ConTeXt}\to\simplifiedcommands -\appendtoks \def\MetaPost{MetaPost}\to\simplifiedcommands -\appendtoks \def\MetaFont{MetaFont}\to\simplifiedcommands -\appendtoks \def\MetaFun{MetaFun}\to\simplifiedcommands -%appendtoks \def||{-}\to\simplifiedcommands -\appendtoks \def|#1|{\ifx#1\empty\empty-\else#1\fi}\to\simplifiedcommands - -\appendtoks\let\buildtextaccent\secondoftwoarguments\to\simplifiedcommands - -% THIS WAS MAIN-002.TEX - -\def\horitems#1#2% #1=breedte #2=commandos - {\scratchdimen#1% - \divide\scratchdimen \nofitems - \!!counta\zerocount - \def\docommand##1% - {\advance\!!counta \plusone - \processaction - [\@@isalign] - [ \v!left=>\hbox to \scratchdimen{\strut##1\hss}, - \v!right=>\hbox to \scratchdimen{\hss\strut##1}, - \v!middle=>\hbox to \scratchdimen{\hss\strut##1\hss}, - \v!margin=>\ifnum\!!counta=\plusone\hss\else\hfill\fi - \strut##1% - \ifnum\!!counta=\nofitems\hss\else\hfill\fi, - \s!default=>\hbox to \scratchdimen{\hss\strut##1\hss}, % midden - \s!unknown=>\hbox to \scratchdimen{\strut##1\hss}]}% % links - \hbox to #1{\hss#2\hss}} - -\def\veritems#1#2% #1=breedte #2=commandos - {\scratchdimen#1% - \def\docommand##1% - {\ifdim\scratchdimen<\zeropoint % the - was a signal - \hbox to -\scratchdimen{\hss\strut##1}% - \else\ifdim\scratchdimen>\zeropoint - \hbox to \scratchdimen{\strut##1\hss}% - \else - \hbox{\strut##1}% - \fi\fi}% - \vbox{#2}} - -\def\dosetupitems[#1]% - {\getparameters[\??is][#1]% - \doif\@@iswidth\v!unknown - {\def\@@iswidth{\hsize}}% - \doifconversiondefinedelse\@@issymbol - {\def\doitembullet##1{\convertnumber{\@@issymbol}{##1}}} - {\doifsymboldefinedelse\@@issymbol - {\def\doitembullet##1{\symbol[\@@issymbol]}}{}}} - -\def\makeitemsandbullets#1% - {\doifelse\@@isn\v!unknown - {\getcommalistsize[#1]% - \edef\nofitems{\commalistsize}} - {\edef\nofitems{\@@isn}}% - \setbox0\hbox - {\doitems \@@iswidth - {\processcommalist[#1]\docommand}}% - \setbox2\hbox - {\doitems \@@isbulletbreedte - {\dorecurse\nofitems - {\docommand{\strut\doitembullet\recurselevel}}}}} - -\def\dostartitems#1#2#3% - {\let\doitems#2% - \def\@@isbulletbreedte{#3}% - \makeitemsandbullets{#1}% - \@@isbefore} - -\def\dostopitems - {\@@isafter - \egroup} - -\setvalue{doitems\v!top}#1% - {\dostartitems{#1}\horitems\@@iswidth - \noindent\vbox - {\forgetall - \doifsomething\@@issymbol - {\doifnot\@@issymbol\v!none - {\box2 - \@@isinbetween - \nointerlineskip}}% - \box0}% - \dostopitems} - -\setvalue{doitems\v!bottom}#1% - {\dostartitems{#1}\horitems\@@iswidth - \noindent\vbox - {\forgetall - \box0 - \doifsomething\@@issymbol - {\@@isinbetween - \nointerlineskip - \box2}}% - \dostopitems} - -\setvalue{doitems\v!inmargin}#1% - {\dostartitems{#1}\veritems{-1.5em}% - is a signal - \noindent\hbox{\llap{\box2\hskip\leftmargindistance}\box0}% - \dostopitems} - -\setvalue{doitems\v!left}#1% - {\advance\hsize -1.5em% - \dostartitems{#1}\veritems{1.5em}% - \noindent\hbox{\box2\box0}% - \dostopitems} - -\setvalue{doitems\v!right}#1% - {\dostartitems{#1}\veritems{0em}% - \noindent\hbox{\box0\hskip-\wd2\box2}% - \dostopitems} - -\unexpanded\def\setupitems - {\dosingleargument\dosetupitems} - -\def\complexitems[#1]% - {\bgroup - \setupitems[#1]% - \parindent\zeropoint - \setlocalhsize - \hsize\localhsize - \dontcomplain - \executeifdefined{doitems\@@islocation}{\getvalue{doitems\v!left}}} - -\definecomplexorsimpleempty\items - -\setupitems - [\c!location=\v!left, - \c!symbol=5, - \c!width=\hsize, - \c!align=\v!middle, - \c!n=\v!unknown, - \c!before=\blank, - \c!inbetween={\blank[\v!medium]}, - \c!after=\blank] - -% there is quite some historic balast in this mechanism, the next variant -% is a first cleanup - -\let\currentparagraph\empty - -\newcount\alcounter \newcount\alnsize \newdimen\alhsize - -\def\paragraphparameter#1% \checkedparameter\??al\currentparagraph#1 - {\executeifdefined{\??al\currentparagraph#1}{\executeifdefined{\??al#1}\empty}} - -\def\paragraphcellmeter#1#2% \checkedparameter\??al\currentparagraph#1 - {\executeifdefined{\??al\currentparagraph\number#1#2}{\paragraphparameter{#2}}} - -\def\dodefineparagraphs[#1][#2]% - {\edef\currentparagraph{#1}% - \setvalue{\s!do\s!next\currentparagraph}% - {\def\\{\getvalue\currentparagraph}}% - \setvalue\currentparagraph - {\getvalue{\s!do\s!next#1}% - \dostartparagraphs{#1}}% - \setvalue{\e!next\currentparagraph}% - {\getvalue{#1}}% - \setvalue{\e!start\currentparagraph}% - {\bgroup - \edef\currentparagraph{#1}% - \letvalueempty{\s!do\s!next\currentparagraph}% - \setvalue{\e!stop\currentparagraph}{\getvalue\currentparagraph\egroup}% - \getvalue\currentparagraph}% - \getparameters[\??al\currentparagraph]% - [%\c!n=3, - %\c!before=\blank, - %\c!after=\blank, - %\c!distance=1em, - %\c!height=\v!fit, - %\c!rule=\v!off, - %\c!command=, - %\c!align=, - %\c!tolerance=\v!tolerant, - %\c!rulethickness=\linewidth, - %\c!rulecolor=, - %\c!style=, - %\c!color=, - %\c!top=, - %\c!top=\vss, - %\c!bottom=\vfill, - #2]% - \setvalue{\e!setup#1\e!endsetup}% - {\setupparagraphs[#1]}% - \dorecurse - {\paragraphparameter\c!n} - {\setupparagraphs - [\currentparagraph] - [\recurselevel] - [\c!width=, - %\c!bottom=\paragraphparameter\c!bottom, - %\c!top=\paragraphparameter\c!top, - %\c!height=\paragraphparameter\c!height, - %\c!rule=\paragraphparameter\c!rule, - %\c!rulethickness=\paragraphparameter\c!rulethickness, - %\c!rulecolor=\paragraphparameter\c!rulecolor, - %\c!align=\paragraphparameter\c!align, - %\c!tolerance=\paragraphparameter\c!tolerance, % obsolete - %\c!distance=\paragraphparameter\c!distance, - \c!style=\paragraphparameter\c!style, - \c!color=\paragraphparameter\c!color]}% - \setupparagraphs[\currentparagraph][1][\c!distance=\zeropoint]} - -\unexpanded\def\defineparagraphs - {\dodoubleargument\dodefineparagraphs} - -\def\dosetupparagraphs[#1][#2][#3]% - {\edef\currentparagraph{#1}% - \ifsecondargument - \doifelse{#2}\v!each - {\dorecurse - {\paragraphparameter\c!n} - {\getparameters[\??al\currentparagraph\recurselevel][#3]}} - {\doifelsenothing{#3} - {\getparameters[\??al\currentparagraph][#2]} - {\def\docommand##1{\getparameters[\??al\currentparagraph##1][#3]}% - \processcommalist[#2]\docommand}}% - \else - \getparameters[\??al][#1]% - \fi} - -\unexpanded\def\setupparagraphs - {\dotripleempty\dosetupparagraphs} - -\setupparagraphs - [\c!n=3, - \c!before=\blank, - \c!after=\blank, - \c!distance=1em, - \c!height=\v!fit, - \c!rule=\v!off, - \c!command=, - \c!align=, - \c!tolerance=\v!tolerant, % obsolete - \c!rulethickness=\linewidth, - \c!rulecolor=, - \c!style=, - \c!color=, - \c!top=, - \c!top=\vss, - \c!bottom=\vfill] - -\def\doparagraphrule - {\doifelse{\paragraphcellmeter\alcounter\c!rule}\v!on - {\linewidth\paragraphcellmeter\alcounter\c!rulethickness - \scratchdimen\dimexpr(\paragraphcellmeter\alcounter\c!distance-\linewidth)/2\relax - \hskip\scratchdimen - \color[\paragraphcellmeter\alcounter\c!rulecolor]{\vrule\!!width\linewidth}% - \hskip\scratchdimen} - {\hskip\paragraphcellmeter\alcounter\c!distance}} - -\def\dostartparagraph - {\doifelsenothing{\paragraphcellmeter\alcounter\c!width} - {\!!widtha\alhsize - \divide\!!widtha \alnsize} - {\!!widtha\paragraphcellmeter\alcounter\c!width}% - \begingroup - \dousestylehashparameter{\??al\currentparagraph\number\alcounter}\c!style - \dousecolorhashparameter{\??al\currentparagraph\number\alcounter}\c!color - \doifelse{\paragraphcellmeter\alcounter\c!height}\v!fit - {\setbox\scratchbox\vtop} - {\setbox\scratchbox\vtop to \paragraphcellmeter\alcounter\c!height}% - \bgroup - \blank[\v!disable]% - \forgetall - \paragraphcellmeter\alcounter\c!top - \paragraphparameter\c!inner - \hsize\!!widtha % setting \wd afterwards removed - \paragraphcellmeter\alcounter\c!inner % twice - \expanded{\setupalign [\paragraphcellmeter\alcounter\c!align ]}% {normal,verytolerant,stretch} - \expanded{\setuptolerance[\paragraphcellmeter\alcounter\c!tolerance]}% obsolete - \ignorespaces - \endgraf - \ignorespaces - % - % Nadeel van de onderstaande constructie is dat \everypar - % binnen een groep kan staan en zo steeds \begstruts - % worden geplaatst. Mooi is anders dus moet het anders! - % - % Hier is \Everypar niet nodig. - % - \everypar{\begstrut\everypar\emptytoks}% - % - \nospace % remove + ignore - \paragraphcellmeter\alcounter\c!command} - -\def\dostopparagraph - {\ifvmode - \removelastskip - \else - \unskip\endstrut\endgraf - \fi - \paragraphcellmeter\alcounter\c!bottom - \egroup - \ifdim\wd\scratchbox=\zeropoint % no data - \wd\scratchbox\!!widtha - \fi - \box\scratchbox - \endgroup - \ifnum\alcounter<\paragraphparameter\c!n\relax - \@EA\doparagraphcell - \else - \@EA\dostopparagraphs - \fi} - -\def\doparagraphcell - {\global\advance\alcounter \plusone - \doifelsenothing{\paragraphcellmeter\alcounter\c!distance} - {\ifnum\alcounter=\plusone\else - \hskip\paragraphparameter\c!distance - \fi} - {\ifnum\alcounter=\plusone - \hskip\paragraphcellmeter\alcounter\c!distance - \else - \doparagraphrule - \fi}% - \letvalue\currentparagraph\dostopparagraph - \dostartparagraph} - -\def\dostartparagraphs#1% - {\bgroup - \edef\currentparagraph{#1}% - \global\alcounter\zerocount - \parindent\zeropoint - \setlocalhsize - \alhsize\localhsize - \alnsize\paragraphparameter\c!n\relax - \dorecurse \alnsize - {\doifelsenothing{\paragraphcellmeter\recurselevel\c!distance} - {\ifnum\recurselevel=\plusone\else - \global\advance\alhsize -\paragraphparameter\c!distance - \fi} - {\global\advance\alhsize -\paragraphcellmeter\recurselevel\c!distance}% - \doifsomething{\paragraphcellmeter\recurselevel\c!width} - {\global\advance\alnsize \minusone - \global\advance\alhsize -\paragraphcellmeter\recurselevel\c!width}}% - %whitespace % gaat fout bij \framed - \paragraphparameter\c!before - \leavevmode % gaat wel goed bij \framed, brrr - \setbox\scratchbox\vbox\bgroup\hbox\bgroup\doparagraphcell} - -\def\dostopparagraphs - {\egroup - \egroup - \iftrue - \hbox{\raise\strutheight\box\scratchbox}% new - \else - \box\scratchbox % old - \fi - \par - \paragraphparameter\c!after - \egroup} - -% Is this used at all? - -\def\dosetuptab[#1]% - {\getparameters[\??ta] - [\c!headstyle=\v!normal, - \c!headcolor=, - \c!style=\v!normal, - \c!color=, - \c!width=\v!broad, - \c!sample={\hskip4em}, - \c!before=, - \c!after=, - #1]% - \definedescription - [tab] - [\c!headstyle=\@@taheadstyle, - \c!headcolor=\@@tacolor, - \c!sample=\@@tasample, - \c!width=\@@tawidth, - \c!before=\@@tabefore, - \c!after=\@@taafter]} - -\unexpanded\def\setuptab - {\dosingleargument\dosetuptab} - -\setuptab - [\c!alternative=\v!left] - -% seldom used, move from kernel to run time module - -\ifx\tfx\undefined \let\tfx\relax \fi - -\def\basegrid - {\dosingleempty\dobasegrid} - -\def\dobasegrid[#1]% - {\begingroup - \getparameters[\??rt] - [\c!x=0,\c!y=0, - \c!nx=10,\c!ny=10, - \c!dx=.5,\c!dy=.5, - \c!xstep=0,\c!ystep=0, - \c!unit=\s!cm, - \c!scale=1, - \c!factor=1, - \c!offset=\v!yes, - \c!location=\v!left, - #1]% - \startpositioning - \dimen0=\@@rtdx\@@rtunit\relax - \dimen0=\@@rtscale\dimen0\relax - \dimen0=\@@rtfactor\dimen0\relax - \multiply\dimen0 \@@rtnx\relax - \dimen2=\@@rtdy\@@rtunit\relax - \dimen2=\@@rtscale\dimen2\relax - \dimen2=\@@rtfactor\dimen2\relax - \multiply\dimen2 \@@rtny\relax - \def\horline - {\vbox - {\hrule - \!!width \dimen0 - \!!height \linewidth - \!!depth \zeropoint}}% - \def\verline - {\vrule - \!!width \linewidth - \!!height \dimen2 - \!!depth \zeropoint}% - \doglobal\newcounter\@@gridc - \doglobal\newcounter\@@gridd - \doglobal\newcounter\@@gride - \def\setlegend##1##2##3% - {\gdef\@@gridc{0}% - \dimen0=2em\relax - \dimen2=##2\@@rtunit\relax - \dimen2=\@@rtscale\dimen2\relax - \dimen2=\@@rtfactor\dimen2\relax - \divide\dimen0 \dimen2\relax - \xdef\@@gride{\number\dimen0}% - \ifnum\@@gride>50 - \gdef\@@gride{100}% - \else\ifnum\@@gride>10 - \gdef\@@gride{50}% - \else\ifnum\@@gride>5 - \gdef\@@gride{10}% - \else\ifnum\@@gride>1 - \gdef\@@gride{5}% - \else - \gdef\@@gride{1}% - \fi\fi\fi\fi - \gdef\@@gridd{0}% - \def\legend - {\ifnum\@@gridd=\zerocount - \vbox - {\increment(\@@gridc,##1)% - \hbox to 2em{\hss\@@gridc\hss}}% - \global\let\@@gridd=\@@gride - \fi - \doglobal\decrement\@@gridd - \doglobal\increment(\@@gridc,##1)}}% - \def\draw##1##2##3##4##5##6##7##8##9% - {\setuppositioning - [\c!state=##8, - \c!xstep=\v!absolute, - \c!ystep=\v!absolute, - \c!unit=\@@rtunit, - \c!scale=\@@rtscale, - \c!factor=\@@rtfactor, - \c!offset=\@@rtoffset, - \c!xoffset=##6, - \c!yoffset=##7]% - \doifelse{##9}\v!middle - {\scratchdimen##3pt\scratchdimen.5\scratchdimen - \edef\@@psxx{\withoutpt\the\scratchdimen}% - \scratchdimen##4pt\scratchdimen.5\scratchdimen - \edef\@@psyy{\withoutpt\the\scratchdimen}% - \scratchcounter##2\advance\scratchcounter -1 - \edef\@@pszz{\the\scratchcounter}} - {\edef\@@psxx{0}\edef\@@psyy{0}\edef\@@pszz{##2}}% - \position(\@@psxx,\@@psyy){##1}% - \setuppositioning - [\c!state=##8, - \c!xstep=\v!relative, - \c!ystep=\v!relative, - \c!scale=\@@rtscale, - \c!factor=\@@rtfactor, - \c!offset=\@@rtoffset, - \c!unit=\@@rtunit]% - \dorecurse\@@pszz{\position(##3,##4){##5}}}% - \draw - \verline\@@rtnx\@@rtdx0\verline\zeropoint\zeropoint\v!start\empty - \draw - \horline\@@rtny0\@@rtdy\horline\zeropoint\zeropoint\v!start\empty - \tfx - \doifnot\@@rtxstep{0} - {\setlegend\@@rtxstep\@@rtdx\@@rtx - \draw\legend\@@rtnx\@@rtdx0\legend{-1em}{-1.5em}\v!overlay\@@rtlocation}% - \doifnot\@@rtystep{0} - {\setlegend\@@rtystep\@@rtdy\@@rty - \draw\legend\@@rtny0\@@rtdy\legend{-2em}{-.75ex}\v!overlay\@@rtlocation}% - \stoppositioning - \endgroup} - -\let\grid\basegrid - -\definetabulate - [\v!legend] - [|emj1|i1|mR|] - -\setuptabulate - [\v!legend] - [\c!unit=.75em,\c!inner=\setquicktabulate\leg,EQ={=}] - -\definetabulate - [\v!legend][\v!two] - [|emj1|emk1|i1|mR|] - -\definetabulate - [\v!fact] - [|R|ecmj1|i1mR|] - -\setuptabulate - [\v!fact] - [\c!unit=.75em,\c!inner=\setquicktabulate\fact,EQ={=}] - -\unexpanded\def\xbox - {\bgroup\aftergroup\egroup\hbox\bgroup\tx\let\next=} - -\unexpanded\def\xxbox - {\bgroup\aftergroup\egroup\hbox\bgroup\txx\let\next=} - -%D This one is for Daniel Pittman, who wanted tight fractions. We show -%D three versions. First the simple one using \type {\low} and \type {high}: -%D -%D \startbuffer -%D \def\vfrac#1#2% -%D {\hbox{\high{\tx#1\kern-.25em}/\low{\kern-.25em\tx#2}}} -%D -%D test \vfrac{1}{2} test \vfrac{123}{456} test -%D \stopbuffer -%D -%D \typebuffer {\showmakeup\getbuffer} -%D -%D A better way to handle the kerning is the following, here -%D we kind of assume that tye slash is symmetrical and has -%D nearly zero width. -%D -%D \startbuffer -%D \def\vfract#1#2% -%D {\hbox{\high{\tx#1}\hbox to \zeropoint{\hss/\hss}\low{\tx#2}}} -%D \stopbuffer -%D -%D \typebuffer {\showmakeup\getbuffer} -%D -%D The third and best alternative is the following: -%D -%D {\showmakeup\getbuffer}\crlf\getbuffer -%D -%D This time we measure the height of the \type {/} and -%D shift over the maximum height and depths of this -%D character and the fractional digits (we use 57 as -%D sample). Here we combine all methods in one macros. - -\setnewconstant\vulgarfractionmethod\plusthree - -\definehspace[vulgarfraction][.25em] % [.15em] -\definesymbol[vulgarfraction][/] % [\raise.2ex\hbox{/}] - -\unexpanded\def\vulgarfraction#1#2% - {\dontleavehmode - \hbox - {\def\vulgarfraction{vulgarfraction}% - \ifcase\vulgarfractionmethod - #1\symbol[\vulgarfraction]#2% - \or - \high{\tx#1\kern-\hspaceamount\empty\vulgarfraction}% - \symbol[\vulgarfraction]% - \low {\kern-\hspaceamount\empty\vulgarfraction\tx#2}% - \or - \high{\tx#1}% - \hbox to \zeropoint{\hss\symbol[\vulgarfraction]\hss}% - \low{\tx#2}% - \or - \setbox0\hbox{\symbol[\vulgarfraction]}% - \setbox2\hbox{\txx57}% - \raise\ht0\hbox{\lower\ht2\hbox{\txx#1}}% - \hbox to \zeropoint{\hss\symbol[\vulgarfraction]\hss}% - \lower\dp0\hbox{\raise\dp2\hbox{\txx#2}}% - \fi}} - -\ifdefined\vfrac \else \let\vfrac\vulgarfraction \fi - -%D \starttabulate -%D \HL -%D \NC \bf method \NC \bf visualization \NC\NR -%D \HL -%D \NC 0 \NC \vulgarfractionmethod0 \vulgarfraction{1}{2} \NC\NR -%D \NC 1 \NC \vulgarfractionmethod1 \vulgarfraction{1}{2} \NC\NR -%D \NC 2 \NC \vulgarfractionmethod2 \vulgarfraction{1}{2} \NC\NR -%D \NC 3 \NC \vulgarfractionmethod3 \vulgarfraction{1}{2} \NC\NR -%D \HL -%D \stoptabulate - -%D Under construction: -%D -%D \starttyping -%D \commalistsentence[aap,noot,mies] -%D \commalistsentence[aap,noot] -%D \commalistsentence[aap] -%D \commalistsentence[a,b,c] -%D \commalistsentence[a,b,c][{ \& },{ and }] -%D \commalistsentence[a,b,c][+,-] -%D \stoptyping - -% obsolete .. use lua instead - -\let\handlecommalistsentence\firstofoneargument - -\def\commalistsentenceone{and-1} -\def\commalistsentencetwo{and-2} - -\def\commalistsentence - {\dodoubleempty\docommalistsentence} - -\def\docommalistsentence[#1][#2]% - {\bgroup - \getfromcommalist[#2][1]% - \ifx\commalistelement\empty - \def\@@commalistsentenceone{\labeltext\commalistsentenceone}% - \else - \let\@@commalistsentenceone\commalistelement - \fi - \getfromcommalist[#2][2]% - \ifx\commalistelement\empty - \def\@@commalistsentencetwo{\labeltext\commalistsentencetwo}% - \else - \let\@@commalistsentencetwo\commalistelement - \fi - \getcommalistsize[#1]% - \ifcase\commalistsize\relax - \def\serializedcommalist{#1}% - \else - \let\serializedcommalist\empty - \scratchcounter\zerocount - \def\docommand##1% - {\advance\scratchcounter \plusone - \ifnum\scratchcounter=\plusone - \scratchtoks{\handlecommalistsentence{##1}}% - \else - \ifnum\scratchcounter=\commalistsize - \appendtoks\@@commalistsentencetwo\handlecommalistsentence{##1}\to\scratchtoks - \else - \appendtoks\@@commalistsentenceone\handlecommalistsentence{##1}\to\scratchtoks - \fi - \fi}% - \processcommacommand[#1]\docommand - \edef\serializedcommalist{\the\scratchtoks}% - \fi - \serializedcommalist - \egroup} - -\def\commacommandsentence[#1]{\@EA\commalistsentence\@EA[#1]} - -\setuplabeltext [\s!nl] [and-1={,} , and-2= en ] % 1, 2 en 3 -\setuplabeltext [\s!en] [and-1={,} , and-2={,} ] % 1, 2, 3 -\setuplabeltext [\s!de] [and-1={,} , and-2= und ] % 1, 2 und 3 -\setuplabeltext [\s!hr] [and-1={,} , and-2= i ] % 1, 2 i 3 - -%D \macros -%D {somekindoftab} -%D -%D This macro can be used to create tabs: -%D -%D \starttyping -%D \setupheadertexts[{\somekindoftab[alternative=horizontal]{\framed{\realfolio}}}] -%D \setuptexttexts [{\somekindoftab[alternative=vertical] {\framed{\realfolio}}}] -%D -%D \starttext -%D \showframe \dorecurse{10}{test\page} -%D \stoptext -%D \stoptyping - -\def\somekindoftab - {\dosingleempty\dosomekindoftab} - -\def\dosomekindoftab[#1]% - {\bgroup - \getparameters[xx] - [\c!alternative=\v!vertical, - \c!width=\textwidth,\c!height=\textheight, - \c!n=\lastpage,\c!m=\realpageno, - #1]% - \doifelse\xxalternative\v!vertical - {\dodosomekindoftab\vbox\vskip\xxheight} - {\dodosomekindoftab\hbox\hskip\xxwidth }} - -\def\dodosomekindoftab#1#2#3#4% - {#1 to #3 \bgroup - \forgetall - \ifnum\xxm>\plusone - #2\zeropoint \!!plus \the\numexpr\xxm -1\relax fill\relax - \fi - #4% - \ifnum\xxm<\xxn\relax - #2\zeropoint \!!plus \the\numexpr\xxn-\xxm\relax fill\relax - \fi - \egroup - \egroup} - -\protect \endinput diff --git a/tex/context/base/core-var.mkiv b/tex/context/base/core-var.mkiv index 854c07867..f9baa8995 100644 --- a/tex/context/base/core-var.mkiv +++ b/tex/context/base/core-var.mkiv @@ -123,6 +123,17 @@ \newtoks \everytable +%D Simplification: + +\newtoks \simplifiedcommands + +\unexpanded\def\simplifycommands + {\the\simplifiedcommands} + +\appendtoks + \let\ =\space +\to \simplifiedcommands + %D State mess: \newtoks \everypushsomestate diff --git a/tex/context/base/enco-ini.mkiv b/tex/context/base/enco-ini.mkiv index a942d5110..816e59d9d 100644 --- a/tex/context/base/enco-ini.mkiv +++ b/tex/context/base/enco-ini.mkiv @@ -43,23 +43,28 @@ %D \macros %D {defineaccent, definecharacter, definecommand} -\unexpanded\def\dodefineaccentcommand#1% - {\setevalue{\string#1}{\noexpand\dohandleaccent{\string#1}}} - -\unexpanded\def\dodefineaccent#1#2#3% no spaces, used low level - {\setvalue{\??ac\string#1\string#2\empty}{#3}} +\installcorenamespace{accents} \unexpanded\def\defineaccent#1 #2 #3 % - {\dodefineaccentcommand{#1}% - \dodefineaccent{#1}{#2}{#3}} - -\def\dohandleaccent#1#2% - {\ifcsname\??ac\string#1#2\empty\endcsname - \csname\??ac\string#1#2\empty\endcsname - \else\ifcsname\??ac\string#1\string#2\empty\endcsname - \csname\??ac\string#1\string#2\empty\endcsname + {\enco_define_accent_command{#1}% + \enco_define_accent{#1}{#2}{#3}} + +\unexpanded\def\enco_define_accent_command#1% + {\setevalue{\string#1}{\enco_handle_accent{\string#1}}} + +\unexpanded\def\enco_define_accent#1#2#3% no spaces, used low level + {\setvalue{\??accents\string#1\string#2\empty}{#3}} + +\unexpanded\def\enco_handle_accent#1#2% + {\ifcsname\??accents\string#1#2\empty\endcsname + \csname\??accents\string#1#2\empty\endcsname + \else\ifcsname\??accents\string#1\string#2\empty\endcsname + \csname\??accents\string#1\string#2\empty\endcsname \fi\fi} +\let\dodefineaccent \enco_define_accent % used at the lua end +\let\dodefineaccentcommand\enco_define_accent_command % used at the lua end + \unexpanded\def\definecharacter#1 #2 % {\doifnumberelse{\string#2} {\setevalue{\string#1}{\utfchar{#2}}} % or {\expandafter\chardef\csname#1\endcsname#2\relax} @@ -77,15 +82,15 @@ %D Accent handling (try to avoid this): -\newbox\accenttestbox % no longer global so we could use \scratchbox +\newbox\b_enco_accent \def\buildmathaccent#1% {\mathaccent#1 } \unexpanded\def\buildtextaccent#1#2% we could do all at the lua end {\begingroup % but that's no fun (yet) - \setbox\accenttestbox\hbox{#1}% - \scratchcounter\cldcontext{nodes.firstcharinbox(\number\accenttestbox)}\relax + \setbox\b_enco_accent\hbox{#1}% + \scratchcounter\cldcontext{nodes.firstcharinbox(\number\b_enco_accent)}\relax \ifcase\scratchcounter\else\accent\scratchcounter\fi \relax#2% \endgroup} @@ -105,7 +110,7 @@ \hidewidth \hskip#2\wd0 \hskip-#3\slantperpoint % in plain 1ex * dimenless value - \vbox to .2ex{\box0\vss}\hidewidth + \vbox to .2\exheight{\box0\vss}\hidewidth \crcr}}} \unexpanded\def\buildtextmacron {\bottomaccent{.25ex}{0}{15}{\textmacron}} @@ -128,7 +133,8 @@ \egroup \egroup} -\def\buildtextgrave{\topaccent{0pt}{0}{15}{\textgrave}} % e.g. +\unexpanded\def\buildtextgrave + {\topaccent{0pt}{0}{15}{\textgrave}} % e.g. \unexpanded\def\definemathaccent#1 #2% {\setvalue{#1}{\mathaccent#2 }} @@ -244,28 +250,28 @@ \let\textvisiblespace\normalcontrolspace \unexpanded\def\fastcontrolspace % no glyph resolving after first (use grouped) - {\dofastcontrolspace} + {\enco_fast_control_space} -\def\dofastcontrolspace +\def\enco_fast_control_space {\iffontchar\font\textcontrolspace - \nofastfallbackcontrolspace + \enco_fast_control_space_nop \else - \dofastfallbackcontrolspace + \enco_fast_control_space_yes \fi - \dofastcontrolspace} + \enco_fast_control_space} -\newbox\controlspacebox +\newbox\b_enco_control_space -\def\nofastfallbackcontrolspace - {\let\dofastcontrolspace\textcontrolspace} +\def\enco_fast_control_space_nop + {\let\enco_fast_control_space\textcontrolspace} -\def\dofastfallbackcontrolspace - {\setbox\controlspacebox\hbox{\space}% - \setbox\controlspacebox\hbox to \wd\controlspacebox{\hss\fallbackcontrolspace\hss}% - \let\dofastcontrolspace\flushcontrolspacebox} +\def\enco_fast_control_space_yes + {\setbox\b_enco_control_space\hbox{\space}% + \setbox\b_enco_control_space\hbox to \wd\b_enco_control_space{\hss\fallbackcontrolspace\hss}% + \let\enco_fast_control_space\flushcontrolspacebox} \def\flushcontrolspacebox - {\copy\controlspacebox} + {\copy\b_enco_control_space} % a few defaults (\{}), we really need the verbose \empty as it will be % stringified .. anyhow, we define this at the lua end now but keep it here as a @@ -289,13 +295,13 @@ % from enco-mis: -\def\fakepercent +\unexpanded\def\fakepercent {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25em/\kern-.2em\normalsubscript{\scriptscriptstyle0}}} -\def\fakeperthousand +\unexpanded\def\fakeperthousand {\mathematics{\normalsuperscript{\scriptscriptstyle0}\kern-.25em/\kern-.2em\normalsubscript{\scriptscriptstyle00}}} -\def\fakepermine +\unexpanded\def\fakepermine {\dontleavehmode \bgroup \setbox\scratchbox\hbox @@ -308,20 +314,20 @@ %D A smaller and bolder variant, more like the math and monospaced ones. -\def\fakeunderscore +\unexpanded\def\fakeunderscore {\relax\ifmmode \vrule\!!depth .12\fontexheight\mathstylefont\normalmathstyle\!!width \fontinterwordspace\mathstylefont\normalmathstyle\!!height\zeropoint\relax \else \dontleavehmode\hbox{\vrule\!!depth .12\fontexheight\font\!!width \fontinterwordspace\font\!!height\zeropoint}% \fi} -\def\fakeunderscores{\let\_\fakeunderscore} -\def\textunderscores{\let\_\textunderscore} +\unexpanded\def\fakeunderscores{\let\_\fakeunderscore} +\unexpanded\def\textunderscores{\let\_\textunderscore} \textunderscores -\ifx\mathunderscore\undefined \let\mathunderscore\fakeunderscore \fi -\ifx\textunderscore\undefined \let\textunderscore\fakeunderscore \fi +\ifdefined\mathunderscore \else \let\mathunderscore\fakeunderscore \fi +\ifdefined\textunderscore \else \let\textunderscore\fakeunderscore \fi \unexpanded\def\normalunderscore{\ifmmode\mathunderscore\else\textunderscore\fi} @@ -349,7 +355,7 @@ \def\periodsdefault{3} % was 5, but now it's like \unknown \unexpanded\def\periods - {\dosingleempty\doperiods} + {\dosingleempty\enco_periods} % \def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 % {\dontleavehmode @@ -361,7 +367,7 @@ % % better for export: -\unexpanded\def\doperiods[#1]% todo: also n=,width= or maybe just #1,#2 +\unexpanded\def\enco_periods[#1]% todo: also n=,width= or maybe just #1,#2 {\dontleavehmode \hbox\bgroup \setbox\scratchbox\hbox to \periodswidth{\hss.\hss}% @@ -377,4 +383,8 @@ % % Hello\fourdots\ World\fourdots \par Hello\fourdots\ World. +\appendtoks + \let\buildtextaccent\secondoftwoarguments +\to \simplifiedcommands + \protect \endinput diff --git a/tex/context/base/font-aux.mkvi b/tex/context/base/font-aux.mkvi index 50cc4a258..bd655e41c 100644 --- a/tex/context/base/font-aux.mkvi +++ b/tex/context/base/font-aux.mkvi @@ -18,84 +18,9 @@ \unprotect -%D \macros -%D {normalizefontheight,normalizefontwidth,normalizedfontsize} -%D -%D Next we introduce some font manipulation macros. When we -%D want to typeset some text spread in a well defined area, it -%D can be considered bad practice to manipulate character and -%D word spacing. In such situations the next few macros can be -%D of help: -%D -%D \starttyping -%D \normalizefontheight \name {sample text} {height} {font} -%D \normalizefontwidth \name {sample text} {width} {font} -%D \stoptyping -%D -%D Consider for instance: -%D -%D \startbuffer[a] -%D \NormalizeFontHeight \TempFont {X} {2\baselineskip} {Serif} -%D \stopbuffer -%D -%D \startbuffer[b] -%D \ruledhbox{\TempFont To Be Or Not To Be} -%D \stopbuffer -%D -%D \typebuffer[a,b] \getbuffer[a] -%D -%D This shows up as: -%D -%D \startlinecorrection -%D \ruledhbox{\getbuffer[b]} -%D \stoplinecorrection -%D -%D The horizontal counterpart is: -%D -%D \startbuffer[a] -%D \NormalizeFontWidth \TempFont {This Line Fits} {\hsize} {Serif} -%D \stopbuffer -%D -%D \startbuffer[b] -%D \ruledhbox{\TempFont This Line Fits} -%D \stopbuffer -%D -%D \typebuffer[a,b] \getbuffer[a] -%D -%D This gives: -%D -%D \startlinecorrection -%D \ruledhbox{\getbuffer[b]} -%D \stoplinecorrection -%D -%D The calculated font scale is avaliable in \type {\normalizedfontsize}. +%D Leftovers: -\unexpanded\def\font_helpers_normalize_size#what#cs#text#width#specification% - {\bgroup - \setbox\scratchbox\hbox{\definedfont[#specification at 10pt]#text}% - \normalexpanded{\egroup\edef\noexpand\normalizedfontsize - {\the\dimexpr\ifdim\wd\scratchbox>\zeropoint - \luaexpr{\number\dimexpr10pt\relax*\number\dimexpr#width\relax/\number#what\scratchbox}\scaledpoint - \else - \bodyfontsize - \fi\relax}}% - \definefont[\strippedcsname#cs][#specification at \normalizedfontsize]} - -\def\NormalizedFontSize{\bodyfontsize} - -\unexpanded\def\normalizefontwidth {\font_helpers_normalize_size\wd} -\unexpanded\def\normalizefontheight{\font_helpers_normalize_size\ht} -\unexpanded\def\normalizefontdepth {\font_helpers_normalize_size\dp} -\unexpanded\def\normalizefontline {\font_helpers_normalize_size\htdp} - -\unexpanded\def\widthspanningtext #text#width#specification{\hbox{\normalizefontwidth \temp{#text}{#width}{#specification}\temp#text}} -\unexpanded\def\heightspanningtext#text#width#specification{\hbox{\normalizefontheight\temp{#text}{#width}{#specification}\temp#text}} -\unexpanded\def\depthspanningtext #text#width#specification{\hbox{\normalizefontdepth \temp{#text}{#width}{#specification}\temp#text}} -\unexpanded\def\linespanningtext #text#width#specification{\hbox{\normalizefontline \temp{#text}{#width}{#specification}\temp#text}} - -\let\NormalizeFontHeight \normalizefontheight -\let\NormalizeFontWidth \normalizefontwidth -\let\WidthSpanningText \widthspanningtext -\def\TheNormalizedFontSize{\normalizefontsize} +\unexpanded\def\xbox {\bgroup\aftergroup\egroup\hbox\bgroup\tx \let\next=} +\unexpanded\def\xxbox{\bgroup\aftergroup\egroup\hbox\bgroup\txx\let\next=} \protect \endinput diff --git a/tex/context/base/lang-lab.lua b/tex/context/base/lang-lab.lua index 360f2aa11..a217cd50d 100644 --- a/tex/context/base/lang-lab.lua +++ b/tex/context/base/lang-lab.lua @@ -64,12 +64,14 @@ local next, rawget, type = next, rawget, type local prtcatcodes = tex.prtcatcodes local lpegmatch = lpeg.match -languages.labels = languages.labels or { } - local trace_labels = false trackers.register("languages.labels", function(v) trace_labels = v end) local report_labels = logs.reporter("languages","labels") -local variables = interfaces.variables +languages.labels = languages.labels or { } +local labels = languages.labels + +local variables = interfaces.variables +local settings_to_array = utilities.parsers.settings_to_array local splitter = lpeg.splitat(":") @@ -77,7 +79,7 @@ local function split(tag) return lpegmatch(splitter,tag) end -languages.labels.split = split +labels.split = split local function definelanguagelabels(data,command,tag,rawtag) for language, text in next, data.labels do @@ -97,7 +99,7 @@ local function definelanguagelabels(data,command,tag,rawtag) end end -function languages.labels.define(command,name,prefixed) +function labels.define(command,name,prefixed) local list = languages.data.labels[name] if list then report_labels("defining label set '%s'",name) @@ -134,7 +136,7 @@ function languages.labels.define(command,name,prefixed) end end ---~ function languages.labels.check() +--~ function labels.check() --~ for category, list in next, languages.data.labels do --~ for tag, specification in next, list do --~ for language, text in next, specification.labels do @@ -147,8 +149,27 @@ end --~ end --~ end --~ ---~ languages.labels.check() +--~ labels.check() -- function commands.setstrippedtextprefix(str) -- context(string.strip(str)) -- end + +function commands.concatcommalist(settings) + local list = settings_to_array(settings.text or "") + local size = #list + if size > 1 then + local set = settings_to_array(settings.separators or "") + local one = set[1] or settings.first or " " + local two = set[2] or settings.second or " " + context(list[1]) + for i=2,size-1 do + context(one) + context(list[i]) + end + context(two) + end + if size > 0 then + context(list[size]) + end +end diff --git a/tex/context/base/lang-lab.mkiv b/tex/context/base/lang-lab.mkiv index a9744f699..0e0c4b31c 100644 --- a/tex/context/base/lang-lab.mkiv +++ b/tex/context/base/lang-lab.mkiv @@ -37,8 +37,6 @@ %D in front as well as after a part number. This is why the %D current implementation of labels supports two labels too. -\ifdefined\simplifiedcommands \else \newtoks\simplifiedcommands \fi - %D \macros %D {setupheadtext, setuplabeltext} %D @@ -298,4 +296,40 @@ {\getparameters[\??lg][#1]% \edef#2{\csname\??lg\currentlanguage\endcsname}} +%D \macros +%D {commalistsentence} +%D +%D Redone in \LUA: +%D +%D \startbuffer +%D \commalistsentence[aap,noot,mies] +%D \commalistsentence[aap,noot] +%D \commalistsentence[aap] +%D \commalistsentence[a,b,c] +%D \commalistsentence[a,b,c][{ \& },{ and }] +%D \commalistsentence[a,b,c][+,-] +%D \stopbuffer +%D +%D \typebuffer +%D +%D \startlines +%D \getbuffer +%D \stoplines + +\unexpanded\def\commalistsentence + {\dodoubleempty\typo_helpers_concat_comma_list} + +\def\typo_helpers_concat_comma_list[#1][#2]% + {\ctxcommand{concatcommalist{ + text = \!!bs#1\!!es, + separators = \!!bs#2\!!es, + first = \!!bs\labeltext{and-1}\!!es, + second = \!!bs\labeltext{and-2}\!!es + }}} + +\setuplabeltext [\s!nl] [and-1={{, }}, and-2={{ en }}] % 1, 2 en 3 +\setuplabeltext [\s!en] [and-1={{, }}, and-2={{, }}] % 1, 2, 3 +\setuplabeltext [\s!de] [and-1={{, }}, and-2={{ und }}] % 1, 2 und 3 +\setuplabeltext [\s!hr] [and-1={{, }}, and-2={{ i }}] % 1, 2 i 3 + \protect \endinput diff --git a/tex/context/base/lang-mis.mkiv b/tex/context/base/lang-mis.mkiv index 3ce6b438f..a537a2936 100644 --- a/tex/context/base/lang-mis.mkiv +++ b/tex/context/base/lang-mis.mkiv @@ -676,8 +676,15 @@ %D \stoptyping \bgroup + \catcode\barasciicode\activecatcode + \unexpanded\gdef\compound#1{|#1|} + + \doglobal \appendtoks + \def|#1|{\ifx#1\empty\empty-\else#1\fi}% + \to \simplifiedcommands + \egroup %D Here we hook some code into the clean up mechanism needed diff --git a/tex/context/base/meta-grd.mkiv b/tex/context/base/meta-grd.mkiv new file mode 100644 index 000000000..da410ba68 --- /dev/null +++ b/tex/context/base/meta-grd.mkiv @@ -0,0 +1,116 @@ +%D \module +%D [ file=meta-grd, +%D version=2012.06.28, +%D title=\METAPOST\ Graphics, +%D subtitle=grids, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{MetaPost Graphics / Grids} + +%D This used to be a \TEX\ method, and a rather old one too. We keep it around but +%D in a more modern way. +%D +%D \startbuffer +%D \basegrid +%D [nx=8,ny=5, +%D dx=.5,dy=.25, +%D unit=cm,scale=2,factor=1, +%D offset=1ex,xstep=2,ystep=1, +%D align=middle,style=\tt\tx] +%D \stopbuffer +%D +%D \typebuffer +%D +%D \placefigure +%D {An example of a grid.} +%D {\getbuffer} + +\startuseMPgraphic{grid}{nx,ny,dx,dy,factor,scale,xstep,ystep,xoffset,yoffset,align} + begingroup ; + + save nx, ny, dx, dy, wd, ht, xstep, ystep, xoffset, yoffset, align, xalign, yalign ; + + numeric nx ; nx := \MPvar{nx} ; + numeric ny ; ny := \MPvar{ny} ; + numeric dx ; dx := \MPvar{factor} * \MPvar{scale} * \MPvar{dx} ; + numeric dy ; dy := \MPvar{factor} * \MPvar{scale} * \MPvar{dy} ; + numeric wd ; wd := nx * dx ; + numeric ht ; ht := ny * dy ; + numeric xstep ; xstep := \MPvar{xstep} ; + numeric ystep ; ystep := \MPvar{ystep} ; + numeric xoffset ; xoffset := \MPvar{xoffset} ; + numeric yoffset ; yoffset := \MPvar{yoffset} ; + numeric align ; align := \MPvar{align} ; + numeric xalign ; xalign := 0 ; + numeric yalign ; yalign := 0 ; + + if align = 1 : + xalign := dx/2 ; + yalign := dy/2 ; + fi ; + + for i=0 step dx until wd : + draw (i,0) -- (i,ht) ; + endfor ; + for i=0 step dy until ht : + draw (0,i) -- (wd,i) ; + endfor ; + + if xstep > 0 : + for i=1 step xstep until nx : + draw thetextext.bot(decimal i,(i*dx-xalign,-xoffset)) ; + endfor ; + fi ; + if ystep > 0 : + for i=1 step ystep until ny : + draw thetextext.lft(decimal i,(-yoffset,i*dy-yalign)) ; + endfor ; + fi ; + + endgroup ; +\stopuseMPgraphic + +\unprotect + +\unexpanded\def\basegrid + {\dosingleempty\typo_grid_base} + +\def\typo_grid_base[#1]% + {\hbox\bgroup + \getdummyparameters + [\c!nx=10,\c!ny=10,\c!dx=.5,\c!dy=.5,\c!xstep=0,\c!ystep=0, + \c!unit=\s!cm,\c!scale=1,\c!factor=1, + \c!offset=.25ex,\c!xoffset=\directdummyparameter\c!offset,\c!yoffset=\directdummyparameter\c!offset, + \c!align=, + #1]% + \usedummystyleandcolor\c!style\c!color + \edef\p_align{\directdummyparameter\c!align}% + \ifx\p_align\v!middle + \let\p_align\!!plusone + \else + \let\p_align\!!zerocount + \fi + \useMPgraphic + {grid}% + {nx=\directdummyparameter\c!nx,% + ny=\directdummyparameter\c!ny,% + dx=\directdummyparameter\c!dx\directdummyparameter\c!unit,% + dy=\directdummyparameter\c!dy\directdummyparameter\c!unit,% + factor=\directdummyparameter\c!factor,% + scale=\directdummyparameter\c!scale,% + xstep=\directdummyparameter\c!xstep,% + ystep=\directdummyparameter\c!ystep,% + xoffset=\directdummyparameter\c!xoffset,% + yoffset=\directdummyparameter\c!yoffset,% + align=\p_align}% + \egroup} + +\let\grid\basegrid + +\protect \endinput diff --git a/tex/context/base/mult-aux.mkiv b/tex/context/base/mult-aux.mkiv index fd90f84f2..ec773f994 100644 --- a/tex/context/base/mult-aux.mkiv +++ b/tex/context/base/mult-aux.mkiv @@ -727,6 +727,12 @@ \expandafter\mult_interfaces_get_parameters_indeed \fi#1} +\mult_interfaces_install_style_and_color_handler + \directdummyparameter + \usedummystyleandcolor + \usedummystyleparameter + \usedummycolorparameter + % Maybe a \definecorenamespace[name][directparameter,directsetup][parent] % but we don't gain much. Actually we might just inline all definitions. diff --git a/tex/context/base/mult-def.mkiv b/tex/context/base/mult-def.mkiv index d7b778a58..a2673f9d2 100644 --- a/tex/context/base/mult-def.mkiv +++ b/tex/context/base/mult-def.mkiv @@ -47,6 +47,7 @@ \def\c!period {period} \def\c!monthconversion{monthconversion} \def\c!comment {comment} +\def\c!textalign {textalign} \def\v!notation {notation} \def\v!endnote {endnote} @@ -64,6 +65,7 @@ \ifdefined\v!kerncharacters\else \def\v!kerncharacters{kerncharacters} \fi % no time now for translations should be a e! actually \ifdefined\v!stretched \else \def\v!stretched {stretched} \fi +\ifdefined\v!vulgarfraction\else \def\v!vulgarfraction{vulgarfraction} \fi % stop todo diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua index c1c35a352..fb4e05d49 100644 --- a/tex/context/base/mult-low.lua +++ b/tex/context/base/mult-low.lua @@ -136,6 +136,8 @@ return { -- "then", -- + "doglobal", "dodoglobal", "redoglobal", "resetglobal", + -- "donothing", "dontcomplain", "forgetall", -- "donetrue", "donefalse", @@ -183,7 +185,7 @@ return { "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", - "scratchnx", "scratchny", + "scratchnx", "scratchny", "scratchmx", "scratchmy", -- "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", @@ -220,6 +222,7 @@ return { "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "copyparameters", -- "getdummyparameters", "dummyparameter", "directdummyparameter", "setdummyparameter", "letdummyparameter", + "usedummystyleandcolor", "usedummystyleparameter", "usedummycolorparameter", -- "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", diff --git a/tex/context/base/mult-sys.mkiv b/tex/context/base/mult-sys.mkiv index ab4931119..f76840971 100644 --- a/tex/context/base/mult-sys.mkiv +++ b/tex/context/base/mult-sys.mkiv @@ -453,9 +453,7 @@ %D \type{@@ag} in composed variables. \definesystemvariable {ab} % AlignedBoxes -\definesystemvariable {ac} % ACcent \definesystemvariable {ae} % AttributEs -\definesystemvariable {al} % ALinea's \definesystemvariable {an} % ANchor \definesystemvariable {as} % AlignmentSwitch \definesystemvariable {bp} % BreakPoint @@ -486,7 +484,6 @@ \definesystemvariable {ih} % InHoudsopgave \definesystemvariable {il} % stelInvulRegelsin \definesystemvariable {ip} % InsertPages -\definesystemvariable {is} % Items \definesystemvariable {it} % stelInTerliniein \definesystemvariable {iv} % stelInvulLijnenin \definesystemvariable {ka} % KAntlijn diff --git a/tex/context/base/node-fin.lua b/tex/context/base/node-fin.lua index 84032c22d..eb8864bff 100644 --- a/tex/context/base/node-fin.lua +++ b/tex/context/base/node-fin.lua @@ -15,6 +15,7 @@ local attributes, nodes, node = attributes, nodes, node local has_attribute = node.has_attribute local copy_node = node.copy +local find_tail = node.slide local nodecodes = nodes.nodecodes local whatcodes = nodes.whatcodes @@ -686,30 +687,27 @@ local function stacker(namespace,attribute,head,default) -- no triggering, no in local id = current.id if id == glyph_code then check() - elseif id == rule_code then - if current.width ~= 0 then - check() - end elseif id == glue_code then local content = current.leader if content and check() then - local ok = false - current.leader, ok = stacker(namespace,attribute,content,attrib) + -- tricky as a leader has to be a list so we cannot inject before + local _, ok = stacker(namespace,attribute,content,attrib) done = done or ok end elseif id == hlist_code or id == vlist_code then local content = current.list if not content then - -- skip + -- skip elseif nslistwise then local a = has_attribute(current,attribute) +-- print(a,attrib,nslistwise[a],a and attrib ~= a and nslistwise[a]) if a and attrib ~= a and nslistwise[a] then -- viewerlayer - local p = attrib - attrib, done = a, true - head = insert_node_before(head,current,copy_node(nsdata[a])) - current.list = stacker(namespace,attribute,content,attrib) + done = true +-- print("yes+",a,nsdata[a].data) + head = insert_node_before(head,current,copy_node(nsdata[a])) + current.list = stacker(namespace,attribute,content,a) head, current = insert_node_after(head,current,copy_node(nsnone)) - attrib = p +-- print("yes-",a,nsnone.data) else local ok = false current.list, ok = stacker(namespace,attribute,content,attrib) @@ -720,6 +718,10 @@ local function stacker(namespace,attribute,head,default) -- no triggering, no in current.list, ok = stacker(namespace,attribute,content,default) done = done or ok end + elseif id == rule_code then + if current.width ~= 0 then + check() + end end previous = current current = current.next diff --git a/tex/context/base/node-typ.lua b/tex/context/base/node-typ.lua index 6540ed478..754b398c4 100644 --- a/tex/context/base/node-typ.lua +++ b/tex/context/base/node-typ.lua @@ -46,7 +46,9 @@ local function tonodes(str,fontid,spacing) -- quick and dirty next = newglyph(fontid or 1,c) spacedone = false end - if not head then + if not next then + -- nothing + elseif not head then head = next else prev.next = next diff --git a/tex/context/base/pack-pos.mkiv b/tex/context/base/pack-pos.mkiv index d14d53751..ff8244f0a 100644 --- a/tex/context/base/pack-pos.mkiv +++ b/tex/context/base/pack-pos.mkiv @@ -99,16 +99,16 @@ \unexpanded\def\pack_positioning_calculate#1#2#3#4#5#6#7#8#9% {\setdimensionwithunit\scratchdimen{#1}{\positioningparameter\c!unit}% - \scratchdimen#8\scratchdimen - \scratchdimen#9\scratchdimen - \advance\scratchdimen #4\relax + \scratchdimen\positioningparameter#8\scratchdimen + \scratchdimen\positioningparameter#9\scratchdimen + \advance\scratchdimen\positioningparameter#4\relax % == \scratchdimen\dimexpr#8\dimexpr#9\scratchdimen\relax+#4\relax - \doif{#2}\v!relative + \doif{\positioningparameter#2}\v!relative {\advance\scratchdimen#3% - \let#4\zeropoint}% + \letpositioningparameter#4\zeropoint}% #3\scratchdimen \doifnot{\positioningparameter\c!state}\v!overlay - {\scratchdimen\dimexpr#5+#3\relax + {\scratchdimen\dimexpr#5\nextbox+#3\relax \ifdim #3<-#7\relax \global#7-#3\relax \fi \ifdim\scratchdimen> #6\relax \global#6\scratchdimen\fi}} @@ -125,27 +125,26 @@ \def\pack_positioning_position_indeed#1#2% {\dontcomplain - \normalexpanded - {\pack_positioning_calculate - {#1}% - {\positioningparameter\c!xstep}% - \d_pack_positioning_x_position - {\positioningparameter\c!xoffset}% - {\wd\nextbox}% - \d_pack_positioning_x_dimension - \d_pack_positioning_x_offset - {\positioningparameter\c!xscale}% - {\positioningparameter\c!xfactor}% - \pack_positioning_calculate - {#2}% - {\positioningparameter\c!ystep}% - \d_pack_positioning_y_position - {\positioningparameter\c!yoffset}% - {\htdp\nextbox}% - \d_pack_positioning_y_dimension - \d_pack_positioning_y_offset - {\positioningparameter\c!yscale}% - {\positioningparameter\c!yfactor}}% + \pack_positioning_calculate + {#1}% + \c!xstep + \d_pack_positioning_x_position + \c!xoffset + \wd + \d_pack_positioning_x_dimension + \d_pack_positioning_x_offset + \c!xscale + \c!xfactor + \pack_positioning_calculate + {#2}% + \c!ystep + \d_pack_positioning_y_position + \c!yoffset + \htdp + \d_pack_positioning_y_dimension + \d_pack_positioning_y_offset + \c!yscale + \c!yfactor \vbox to \zeropoint {\vskip\d_pack_positioning_y_position \hbox to \zeropoint diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 260e49054..5c835ba6f 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index bd5feeee5..9a2a5fefd 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf differ diff --git a/tex/context/base/status-mkiv.lua b/tex/context/base/status-mkiv.lua index 07ba31a8e..3da404199 100644 --- a/tex/context/base/status-mkiv.lua +++ b/tex/context/base/status-mkiv.lua @@ -354,7 +354,7 @@ return { { filename = "enco-ini", marktype = "mkiv", - status = "messy", + status = "okay", }, { filename = "hand-ini", @@ -825,6 +825,11 @@ return { marktype = "mkiv", status = "okay", }, + { + filename = "typo-itm", + marktype = "mkiv", + status = "okay", + }, { filename = "buff-ini", marktype = "mkiv", @@ -946,6 +951,11 @@ return { status = "okay", comment = "frozen functionaly so no drastic cleanup", }, + { + filename = "tabl-mis", + marktype = "mkiv", + status = "okay", + }, { filename = "tabl-nte", marktype = "mkiv", @@ -1214,6 +1224,11 @@ return { status = "okay", comment = "might get updated when mp code gets cleaned up", }, + { + filename = "meta-grd", + marktype = "mkiv", + status = "okay", + }, { filename = "page-mrk", marktype = "mkiv", @@ -1385,11 +1400,11 @@ return { marktype = "mkiv", status = "unknown", }, - { - filename = "core-mis", - marktype = "mkiv", - status = "unknown", - }, + -- { + -- filename = "core-mis", + -- marktype = "mkiv", + -- status = "unknown", + -- }, { filename = "pack-com", marktype = "mkiv", diff --git a/tex/context/base/status-mkiv.tex b/tex/context/base/status-mkiv.tex index 266e26966..99c281c00 100644 --- a/tex/context/base/status-mkiv.tex +++ b/tex/context/base/status-mkiv.tex @@ -23,10 +23,10 @@ \setupheadertexts [\currentdate][MkIV Status / Page \pagenumber] -\starttext +% \showmakeup +\showallmakeup -% anch attr back buff colo font grph java lang luat lxml math meta mlib mult node -% pack page phys scrn spac strc supp symb syst tabl toks typo +\starttext \starttitle[title=Todo] diff --git a/tex/context/base/strc-des.mkvi b/tex/context/base/strc-des.mkvi index 29072fbc6..129370771 100644 --- a/tex/context/base/strc-des.mkvi +++ b/tex/context/base/strc-des.mkvi @@ -240,4 +240,23 @@ {\csname\??constructionstophandler\v!construction\endcsname \endgroup} +%D For historic rasons we have (from now on undocumented): + +\definedescription + [tab] + [\c!alternative=\v!left, + \c!headstyle=\v!normal, + \c!headcolor=, + \c!style=\v!normal, + \c!color=, + \c!width=\v!broad, + \c!sample=\hskip4\emwidth, + \c!before=, + \c!after=] + +\unexpanded\def\setuptab + {\setupdescription[tab]} + +%D Maybe we should remove this definition. + \protect \endinput diff --git a/tex/context/base/syst-ini.mkiv b/tex/context/base/syst-ini.mkiv index 9b94ef428..b459ffffd 100644 --- a/tex/context/base/syst-ini.mkiv +++ b/tex/context/base/syst-ini.mkiv @@ -371,6 +371,9 @@ \newcount\scratchnx \newcount\scratchny +\newcount\scratchmx +\newcount\scratchmy + %D More allocations: \newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt diff --git a/tex/context/base/tabl-mis.mkiv b/tex/context/base/tabl-mis.mkiv new file mode 100644 index 000000000..f2666cf40 --- /dev/null +++ b/tex/context/base/tabl-mis.mkiv @@ -0,0 +1,288 @@ +%D \module +%D [ file=tabl-mis, +%D version=2012.06.28, +%D title=\CONTEXT\ Table Macros, +%D subtitle=Miscellaneous, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Table Macros / Miscellaneous} + +\unprotect + +%D \macros +%D {somekindoftab,kindoftabposition} +%D +%D This macro can be used to create tabs: +%D +%D \starttyping +%D \setupheadertexts[{\somekindoftab[alternative=horizontal]{\framed{\kindoftabposition}}}] +%D \setuptexttexts [{\somekindoftab[alternative=vertical] {\framed{\kindoftabposition}}}] +%D +%D \starttext +%D \showframe \dorecurse{10}{test\page} +%D \stoptext +%D \stoptyping +%D +%D (This rather old but updated code used to be in \type {core-mis.mkiv}.) + +\let\kindoftabposition\!!zerocount + +\unexpanded\def\somekindoftab + {\dosingleempty\typo_kindoftab} + +\def\typo_kindoftab[#1]% + {\bgroup + \getdummyparameters + [\c!alternative=\v!vertical, + \c!width=\textwidth,\c!height=\textheight, + \c!n=\lastpage,\c!m=\realpageno, + #1]% + \doifelse{\directdummyparameter\c!alternative}\v!vertical + {\typo_kindoftab_indeed\vbox\vskip\c!height} + {\typo_kindoftab_indeed\hbox\hskip\c!width }} + +\def\typo_kindoftab_indeed#1#2#3#4% + {#1 to \directdummyparameter#3 \bgroup + \forgetall + \scratchnx\directdummyparameter\c!n\relax + \scratchmx\directdummyparameter\c!m\relax + \edef\kindoftabposition{\the\scratchmx}% + \ifnum\scratchmx>\plusone + #2\zeropoint \!!plus \the\numexpr\scratchmx-\plusone \relax\!!fill\relax + \fi + #4% can use \kindoftabposition + \ifnum\scratchmx<\scratchnx\relax + #2\zeropoint \!!plus \the\numexpr\scratchnx-\scratchmx\relax\!!fill\relax + \fi + \egroup + \egroup} + +%D The following paragraphs mechanism is probably one of the oldest of +%D \CONTEXT\ and mostly served as a table mechanism capable of dealing +%D with paragraphs. Nowadays one can also use tabulate or natural tables. +%D +%D \startbuffer +%D \defineparagraphs[sample][n=2,rule=on] +%D +%D \startsample +%D first \nextsample +%D second \nextsample +%D third +%D \stopsample +%D +%D \startsample +%D \input tufte \nextsample +%D \input ward \nextsample +%D \input davis \nextsample +%D \input zapf +%D \stopsample +%D +%D \startparagraphs[sample] +%D first \nextsample +%D second \nextsample +%D third +%D \stopparagraphs +%D +%D \startparagraphs[sample] +%D \startparagraphscell +%D first +%D \stopparagraphscell +%D \startparagraphscell +%D second +%D \stopparagraphscell +%D \startparagraphscell +%D third +%D \stopparagraphscell +%D \stopparagraphs +%D \stopbuffer +%D +%D \typebuffer \getbuffer + +\installcorenamespace{paragraphs} + +\installcommandhandler \??paragraphs {paragraphs} \??paragraphs + +\setupparagraphs + [\c!n=3, + \c!before=\blank, + \c!after=\blank, + \c!distance=\emwidth, + \c!height=\v!fit, + \c!width=\availablehsize, + \c!rule=\v!off, + \c!command=, + \c!align=, + \c!tolerance=\v!tolerant, % obsolete + \c!rulethickness=\linewidth, + \c!rulecolor=, + \c!style=, + \c!color=, + \c!top=\vss, + \c!bottom=\vfill] + +\let\typo_paragraphs_setup_saved\setupparagraphs + +\unexpanded\def\setupparagraphs + {\dotripleempty\typo_paragraphs_setup} + +\def\typo_paragraphs_setup[#1][#2][#3]% we are downward compatible with [each] and [1,3] + {\ifthirdargument + \def\typo_paragraphs_setup_three[#1][#2][#3]% + {\doifelse{#2}\v!each + {\typo_paragraphs_setup_saved[#1][#3]} + {\def\typo_paragraphs_setup_step##1{\typo_paragraphs_setup_saved[#1:##1][#3]}% + \processcommalist[#2]\typo_paragraphs_setup_step}} + \else\ifsecondargument + \typo_paragraphs_setup_saved[#1][#2]% + \else\iffirstargument + \typo_paragraphs_setup_saved[#1]% + \fi\fi\fi} + +\appendtoks + \letvalue {\e!next \currentparagraphs}\nextparagraphs + \setuevalue{\e!start\currentparagraphs}{\startparagraphs[\currentparagraphs]}% + \letvalue {\e!stop \currentparagraphs}\stopparagraphs + %setuevalue{\e!setup\currentparagraph\e!endsetup}{\typo_paragraphs_setup_saved[\currentparagraphs]}% + \dorecurse{\paragraphsparameter\c!n} + {\normalexpanded{\typo_paragraphs_setup_saved[\currentparagraphs:\recurselevel][\c!width=,\s!parent=\??paragraphs\currentparagraphs]}}% + \typo_paragraphs_setup_saved[\currentparagraphs:1][\c!distance=\zeropoint]% +\to \everydefineparagraphs + +\newcount\c_typo_paragraphs_n +\newcount\c_typo_paragraphs_max +\newdimen\d_typo_paragraphs_width +\newdimen\d_typo_paragraphs_auto + +\unexpanded\def\startparagraphs[#1]% quite slow + {\bgroup % (1) + \edef\currentparagraphs{#1}% + \paragraphsparameter\c!before + \edef\p_width{\paragraphsparameter\c!width}% + \ifx\p_width\empty + \d_typo_paragraphs_width\availablehsize + \else + \d_typo_paragraphs_width\p_width\relax + \fi + \c_typo_paragraphs_max\paragraphsparameter\c!n\relax + \d_typo_paragraphs_auto\d_typo_paragraphs_width\relax + \scratchcounter\zerocount + \dorecurse\c_typo_paragraphs_max + {\edef\p_width{\namedparagraphsparameter{\currentparagraphs:\recurselevel}\c!width}% + \ifx\p_width\empty + \advance\scratchcounter\plusone + \else + \advance\d_typo_paragraphs_auto-\p_width\relax + \fi + \ifnum\recurselevel>\plusone + \advance\d_typo_paragraphs_auto-\namedparagraphsparameter{\currentparagraphs:\recurselevel}\c!distance\relax + \fi}% + \ifnum\scratchcounter>\zerocount + \divide\d_typo_paragraphs_auto\scratchcounter + \else + \d_typo_paragraphs_auto\zeropoint + \fi + \parindent\zeropoint + \c_typo_paragraphs_n\zerocount + \let\\=\typo_paragraphs_next % downward compatible + \dontleavehmode\hbox + \bgroup % (2) + \forgetall + \let\typo_paragraphs_start_cell\typo_paragraphs_start_cell_indeed + \let\typo_paragraphs_stop_cell \typo_paragraphs_stop_cell_indeed + \typo_paragraphs_start_cell_indeed} + +\unexpanded\def\stopparagraphs + {\stopparagraphscell + \egroup % (2) + \paragraphsparameter\c!after + \egroup} % (1) + +\unexpanded\def\nextparagraphs + {\stopparagraphscell + \startparagraphscell} + +\unexpanded\def\startparagraphscell + {\typo_paragraphs_start_cell} + +\def\typo_paragraphs_start_cell_indeed + {\removeunwantedspaces + \advance\c_typo_paragraphs_n\plusone + \ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max + \expandafter\typo_paragraphs_start_cell_nop + \else + \expandafter\typo_paragraphs_start_cell_yes + \fi} + +\def\typo_paragraphs_start_cell_nop + {\begingroup + % message: too many cells in paragraphs + \let\typo_paragraphs_start_cell\relax + \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed + \setbox\scratchbox\vbox\bgroup} + +\def\typo_paragraphs_start_cell_yes + {\begingroup + \let\typo_paragraphs_start_cell\relax + \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed + \edef\currentparagraphs{\currentparagraphs:\the\c_typo_paragraphs_n}% + \ifnum\c_typo_paragraphs_n>\plusone + \typo_paragraphs_separator + \fi + \edef\p_height{\paragraphsparameter\c!height}% + \edef\p_width {\paragraphsparameter\c!width }% + \useparagraphsstyleandcolor\c!style\c!color + \setbox\scratchbox\vtop \ifx\p_height\empty \else\ifx\p_height\v!fit \else to \p_height \fi\fi + \bgroup % (2) + \blank[\v!disable]% + \paragraphsparameter\c!top + \hsize\ifx\p_width\empty \d_typo_paragraphs_auto \else \p_width \fi \relax + \usealignparameter\paragraphsparameter + \paragraphsparameter\c!inner + \everypar{\begstrut\everypar\emptytoks}% + \ignorespaces + \paragraphsparameter\c!command} + +\unexpanded\def\stopparagraphscell + {\typo_paragraphs_stop_cell + \let\typo_paragraphs_stop_cell\relax} + +\def\typo_paragraphs_stop_cell_indeed + {\ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max + \expandafter\typo_paragraphs_stop_cell_nop + \else + \expandafter\typo_paragraphs_stop_cell_yes + \fi} + +\def\typo_paragraphs_stop_cell_nop + {\egroup + \endgroup} + +\def\typo_paragraphs_stop_cell_yes + {\ifvmode + \removelastskip + \else + \removeunwantedspaces + \endstrut + \endgraf + \fi + \paragraphsparameter\c!bottom + \egroup % (2) + \dontleavehmode\hbox{\raise\strutheight\box\scratchbox}% + \endgroup} + +\def\typo_paragraphs_separator + {\scratchdistance\paragraphsparameter\c!distance + \doif{\paragraphsparameter\c!rule}\v!on + {\scratchwidth\paragraphsparameter\c!rulethickness + \scratchdistance\dimexpr(\scratchdistance-\scratchwidth)/2\relax + \hskip\scratchdistance + \color[\paragraphsparameter\c!rulecolor]{\vrule\!!width\scratchwidth}}% + \hskip\scratchdistance} + +\protect \endinput diff --git a/tex/context/base/tabl-ntb.mkiv b/tex/context/base/tabl-ntb.mkiv index 5045075db..4d2f8cc15 100644 --- a/tex/context/base/tabl-ntb.mkiv +++ b/tex/context/base/tabl-ntb.mkiv @@ -1,5 +1,5 @@ %D \module -%D [ file=core-ntb, +%D [ file=tabl-ntb, %D version=2000.04.18, %D title=\CONTEXT\ Table Macros, %D subtitle=Natural Tables, diff --git a/tex/context/base/tabl-tbl.mkiv b/tex/context/base/tabl-tbl.mkiv index cd5bd8a06..e4792efa1 100644 --- a/tex/context/base/tabl-tbl.mkiv +++ b/tex/context/base/tabl-tbl.mkiv @@ -1303,7 +1303,7 @@ \expandafter\ignorespaces % interferes with the more tricky hooks \fi} -\def\setquicktabulate#1% see \startlegend \startgiven (for the moment still public) +\unexpanded\def\setquicktabulate#1% see \startlegend \startgiven (for the moment still public) {\let#1\tabl_tabulate_column_inject_auto \let\\\tabl_tabulate_column_inject_auto} % brrr, will go @@ -2238,4 +2238,26 @@ % \NC \digits $@@@.@@1,@@$ \NC\NR % \stoptabulatie +%D Predefined categories (moved from core-mis): + +\definetabulate + [\v!legend] + [|emj1|i1|mR|] + +\setuptabulate + [\v!legend] + [\c!unit=.75em,\c!inner=\setquicktabulate\leg,EQ={=}] + +\definetabulate + [\v!legend][\v!two] + [|emj1|emk1|i1|mR|] + +\definetabulate + [\v!fact] + [|R|ecmj1|i1mR|] + +\setuptabulate + [\v!fact] + [\c!unit=.75em,\c!inner=\setquicktabulate\fact,EQ={=}] + \protect \endinput diff --git a/tex/context/base/trac-vis.lua b/tex/context/base/trac-vis.lua index 556dc1347..ca606939b 100644 --- a/tex/context/base/trac-vis.lua +++ b/tex/context/base/trac-vis.lua @@ -137,8 +137,13 @@ local modes = { glyph = 512, } -local makeup_modes = { "hbox", "vbox", "vtop", "kern", "glue", "penalty" } -local all_modes = { "hbox", "vbox", "vtop", "kern", "glue", "penalty", "fontkern", "whatsit", "glyph" } +-- local modes_makeup = { "hbox", "vbox", "vtop", "kern", "glue", "penalty" } +-- local modes_boxes = { "hbox", "vbox", "vtop" } +-- local modes_all = { "hbox", "vbox", "vtop", "kern", "glue", "penalty", "fontkern", "whatsit", "glyph" } + +local modes_makeup = { "hbox", "vbox", "kern", "glue", "penalty" } +local modes_boxes = { "hbox", "vbox" } +local modes_all = { "hbox", "vbox", "kern", "glue", "penalty", "fontkern", "whatsit", "glyph" } local usedfont, exheight, emwidth local l_penalty, l_glue, l_kern, l_fontkern, l_hbox, l_vbox, l_vtop, l_strut, l_whatsit, l_glyph @@ -156,15 +161,19 @@ local function setvisual(n,a,what) -- this will become more efficient when we ha if not n or n == "reset" then return unsetvalue elseif n == "makeup" then - for i=1,#makeup_modes do - a = setvisual(makeup_modes[i],a) + for i=1,#modes_makeup do + a = setvisual(modes_makeup[i],a) + end + elseif n == "boxes" then + for i=1,#modes_boxes do + a = setvisual(modes_boxes[i],a) end elseif n == "all" then if what == false then return unsetvalue else - for i=1,#all_modes do - a = setvisual(all_modes[i],a) + for i=1,#modes_all do + a = setvisual(modes_all[i],a) end end else @@ -243,9 +252,10 @@ for mode, value in next, modes do trackers.register(format("visualizers.%s",mode), function(v) set(mode,v) end) end +trackers.register("visualizers.reset", function(v) set("reset", v) end) trackers.register("visualizers.all", function(v) set("all", v) end) trackers.register("visualizers.makeup",function(v) set("makeup",v) end) -trackers.register("visualizers.reset", function(v) set("reset", v) end) +trackers.register("visualizers.boxes", function(v) set("boxes", v) end) local c_positive = "trace:b" local c_negative = "trace:r" @@ -278,11 +288,14 @@ local function sometext(str,layer,color) } setlisttransparency(info,c_zero) info = fast_hpack(info) - set_attribute(info,a_layer,layer) + if layer then + set_attribute(info,a_layer,layer) + end + local width = info.width info.width = 0 info.height = 0 info.depth = 0 - return info + return info, width end local f_cache = { } @@ -337,21 +350,21 @@ local function whatsit(head,current) return head, current end -local b_cache +local b_cache = { } -local function ruledbox(head,current,vertical,layer) +local function ruledbox(head,current,vertical,layer,what) local wd = current.width if wd ~= 0 then local ht, dp = current.height, current.depth local next, prev = current.next, current.prev current.next, current.prev = nil, nil - local linewidth = .1 * emwidth + local linewidth = emwidth/10 local baseline if dp ~= 0 and ht ~= 0 then - if not b_cache then - -- due to an optimized leader color/transparency we need to se the glue node in order + baseline = b_cache.baseline + if not baseline then + -- due to an optimized leader color/transparency we need to set the glue node in order -- to trigger this mechanism - b_cache = new_glue(0) local leader = concat_nodes { new_glue(2.5*linewidth), new_rule(5*linewidth,linewidth,0), @@ -360,13 +373,15 @@ local function ruledbox(head,current,vertical,layer) -- setlisttransparency(leader,c_text) leader = fast_hpack(leader) -- setlisttransparency(leader,c_text) - b_cache.leader = leader - b_cache.subtype = cleaders_code - b_cache.spec.stretch = 65536 - b_cache.spec.stretch_order = 2 - setlisttransparency(b_cache,c_text) + baseline = new_glue(0) + baseline.leader = leader + baseline.subtype = cleaders_code + baseline.spec.stretch = 65536 + baseline.spec.stretch_order = 2 + setlisttransparency(baseline,c_text) + b_cache.baseline = baseline end - baseline = copy_list(b_cache) + baseline = copy_list(baseline) baseline = fast_hpack(baseline,wd-2*linewidth) -- or new hpack node, set head and also: -- baseline.width = wd @@ -374,7 +389,22 @@ local function ruledbox(head,current,vertical,layer) -- baseline.glue_order = 2 -- baseline.glue_sign = 1 end + local this = b_cache[what] + if not this then + local text = fast_hpack_string(what,usedfont) + this = concat_nodes { + new_kern(-text.width), + text, + } + setlisttransparency(this,c_text) + this = fast_hpack(this) + this.width = 0 + this.height = 0 + this.depth = 0 + b_cache[what] = this + end local info = concat_nodes { + copy_list(this), -- this also triggets the right mode (else sometimes no whatits) new_rule(linewidth,ht,dp), new_rule(wd-2*linewidth,-dp+linewidth,dp), new_rule(linewidth,ht,dp), @@ -396,10 +426,13 @@ local function ruledbox(head,current,vertical,layer) new_kern(-wd), info, } - info = fast_hpack(info) + info = fast_hpack(info,wd) if vertical then info = vpack_nodes(info) end +-- info.width = wd +-- info.height = ht +-- info.depth = dp if next then info.next = next next.prev = info @@ -424,7 +457,7 @@ local function ruledglyph(head,current) local ht, dp = current.height, current.depth local next, prev = current.next, current.prev current.next, current.prev = nil, nil - local linewidth = .05 * emwidth + local linewidth = emwidth/20 local baseline if dp ~= 0 and ht ~= 0 then baseline = new_rule(wd-2*linewidth,linewidth,0) @@ -603,10 +636,10 @@ local function visualize(head,vertical) local attr = unsetvalue while current do local id = current.id - local a = has_attribute(current,a_visual) + local a = has_attribute(current,a_visual) or unsetvalue if a ~= attr then prev_trace_fontkern = trace_fontkern - if not a then + if a == unsetvalue then trace_hbox = false trace_vbox = false trace_vtop = false @@ -685,7 +718,7 @@ local function visualize(head,vertical) current.list = visualize(content,false) end if trace_hbox then - head, current = ruledbox(head,current,false,l_hbox) + head, current = ruledbox(head,current,false,l_hbox,"H__") end elseif id == vlist_code then local content = current.list @@ -693,9 +726,9 @@ local function visualize(head,vertical) current.list = visualize(content,true) end if trace_vtop then - head, current = ruledbox(head,current,true,l_vtop) + head, current = ruledbox(head,current,true,l_vtop,"_T_") elseif trace_vbox then - head, current = ruledbox(head,current,true,l_vbox) + head, current = ruledbox(head,current,true,l_vbox,"__V") end elseif id == whatsit_code then if trace_whatsit then @@ -727,11 +760,8 @@ local function cleanup() np, p_cache = freed(p_cache) nk, k_cache = freed(k_cache) nw, w_cache = freed(w_cache) - if b_cache then - free_node_list(b_cache) - b_cache = nil - end - -- report_visualize("cache: %s fontkerns, %s skips, %s penalties, %s kerns, %s whatsits",nf,ng,np,nk,nw) + nb, b_cache = freed(b_cache) + -- report_visualize("cache: %s fontkerns, %s skips, %s penalties, %s kerns, %s whatsits, %s boxes",nf,ng,np,nk,nw,nb) end function visualizers.handler(head) diff --git a/tex/context/base/trac-vis.mkiv b/tex/context/base/trac-vis.mkiv index dfceb379f..292f60d62 100644 --- a/tex/context/base/trac-vis.mkiv +++ b/tex/context/base/trac-vis.mkiv @@ -60,6 +60,11 @@ \let\vtop \ruledvtop \showstruts} +\unexpanded\def\showboxes + {\ctxcommand{setvisual("boxes")}% + \let\normalvtop\ruledvtop + \let\vtop \ruledvtop} + \unexpanded\def\showglyphs {\ctxcommand{setvisual("glyph")}} @@ -121,17 +126,4 @@ \let\ruledmskip \mskip \let\ruledpenalty \penalty -%D And for some time we will keep these as well: - -\let\showfils \relax -\let\dontshowfils \relax -\let\showboxes \relax -\let\dontshowboxes \relax -\let\showskips \relax -\let\dontshowskips \relax -\let\showpenalties \relax -\let\dontshowpenalties \relax -\let\showcomposition \relax -\let\dontshowcomposition \relax - \protect \endinput diff --git a/tex/context/base/typo-itm.mkiv b/tex/context/base/typo-itm.mkiv new file mode 100644 index 000000000..eb47e4076 --- /dev/null +++ b/tex/context/base/typo-itm.mkiv @@ -0,0 +1,273 @@ +%D \module +%D [ file=typo-itm, % comes from core-mis +%D version=2012.06.28, +%D title=\CONTEXT\ Typesetting Macros, +%D subtitle=Item Lists, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Node Macros / Item Lists} + +\unprotect + +%D This is a real old mechanism that we once used for questionaries. As it is documented +%D we keep it around. A more modern implementation would probably use another approach +%D but I don't want to spend too much time on it now. There are a couple of changes: +%D +%D \startitemize +%D \startitem textwidth sets the combined width \stopitem +%D \startitem width sets the symbolwidth \stopitem +%D \startitem alternative is used instead of location \stopitem +%D \stopitemize +%D +%D \startbuffer +%D \items[alternative=left]{a,b,c} +%D \items[alternative=left,align=middle,textalign=flushright,distance=1em]{a,b,c} +%D \items[alternative=right]{a,b,c} +%D \items[alternative=inmargin]{a,b,c} +%D \items[alternative=top]{a,b,c} +%D \items[alternative=bottom]{a,b,c} +%D \items[alternative=bottom,align=flushleft,textstyle=bold,color=red,textcolor=green]{a,b,c} +%D \stopbuffer +%D +%D \typebuffer +%D +%D This renders as: +%D +%D \getbuffer + +\installcorenamespace{items} +\installcorenamespace{itemsalternatives} +\installcorenamespace{itemshorizontal} +\installcorenamespace{itemsvertical} + +\installcommandhandler \??items {items} \??items + +\setupitems + [\c!alternative=\v!left, + \c!symbol=5, + \c!textwidth=\availablehsize, + \c!align=\v!middle, + \c!textalign=\v!flushleft, + \c!distance=\zeropoint, + %\c!n=, + \c!before=\blank, + \c!inbetween={\blank[\v!medium]}, + \c!after=\blank] + +\unexpanded\def\items + {\dosingleempty\typo_items_process} + +\newcount\c_typo_items_n +\newcount\c_typo_items_m +\newdimen\d_typo_items_text_width +\newdimen\d_typo_items_symbol_width +\newdimen\d_typo_items_distance +\newbox \b_typo_items_symbols +\newbox \b_typo_items_texts + +\def\typo_items_process[#1]#2% + {\bgroup + \setupitems[#1]% + \edef\p_typo_items_alternative{\itemsparameter\c!alternative}% + \ifcsname\??itemsalternatives\p_typo_items_alternative\endcsname \else + \let\p_typo_items_alternative\v!left + \fi + \let\currentitems\p_typo_items_alternative + \setupcurrentitems[#1]% + % + \edef\p_typo_items_textwidth{\itemsparameter\c!textwidth}% + \ifx\p_typo_items_textwidth\empty + \d_typo_items_text_width\availablehsize + \else + \d_typo_items_text_width\p_typo_items_textwidth\relax + \fi + % + \edef\p_typo_items_width{\itemsparameter\c!width}% + \ifx\p_typo_items_width\empty + \d_typo_items_symbol_width1.5\emwidth + \else + \d_typo_items_symbol_width\p_typo_items_width\relax + \fi + % + \edef\p_typo_items_distance{\itemsparameter\c!distance}% + \ifx\p_typo_items_distance\empty + \d_typo_items_distance\zeropoint + \else + \d_typo_items_distance\p_typo_items_distance\relax + \fi + % + \edef\p_typo_items_symbol{\itemsparameter\c!symbol}% + \ifx\p_typo_items_symbol\empty + \let\m_typo_items_symbol\firstofoneargument + \else\ifx\p_typo_items_symbol\v!none + \let\p_typo_items_symbol\empty + \let\m_typo_items_symbol\firstofoneargument + \else + \doifconversiondefinedelse\p_typo_items_symbol + {\def\m_typo_items_symbol{\convertnumber\p_typo_items_symbol}} + {\doifsymboldefinedelse\p_typo_items_symbol + {\def\m_typo_items_symbol{\symbol[\p_typo_items_symbol]\gobbleoneargument}} + {\let\m_typo_items_symbol\firstofoneargument}}% + \fi\fi + % + \edef\p_typo_items_align{\itemsparameter\c!align}% + \edef\p_typo_items_textalign{\itemsparameter\c!textalign}% + % + \edef\p_typo_items_n{\itemsparameter\c!n}% + \ifx\p_typo_items_n\empty + \getcommalistsize[#2]% + \c_typo_items_n\commalistsize\relax + \else + \c_typo_items_n\p_typo_items_n\relax + \fi + % + \parindent\zeropoint + \dontcomplain + % + \itemsparameter\c!before + \csname\??itemsalternatives\p_typo_items_alternative\endcsname{#2}% + \itemsparameter\c!after + \egroup} + +% rendering + +\setvalue{\??itemshorizontal\v!margin}#1% + {\ifnum\c_typo_items_m=\plusone\hss\else\hfill\fi + \strut#1% + \ifnum\c_typo_items_m=\c_typo_items_n\hss\else\hfill\fi} + +\setvalue{\??itemshorizontal\s!unknown}% + {\simplealignedbox\scratchwidth\m_typo_items_align} + +\def\typo_items_item_horizontal + {\advance\c_typo_items_m\plusone + \csname\??itemshorizontal + \ifcsname\??itemshorizontal\p_typo_items_align\endcsname + \p_typo_items_align + \else + \s!unknown + \fi + \endcsname} + +\setvalue{\??itemsvertical\s!unknown}% + {\simplealignedbox\scratchwidth\m_typo_items_align} + +\def\typo_items_item_vertical + {\advance\c_typo_items_m\plusone + \csname\??itemsvertical + \ifcsname\??itemsvertical\p_typo_items_align\endcsname + \p_typo_items_align + \else + \s!unknown + \fi + \endcsname} + +\def\typo_items_make_horizontal#1% + {\divide\scratchwidth\c_typo_items_n + \hbox{#1}} + +\def\typo_items_make_vertical#1% + {\vbox{#1}} + +\def\typo_items_construct_items_boxes#1% + {\setbox\b_typo_items_texts\hbox + {\c_typo_items_m\zerocount + \let\m_typo_items_align\p_typo_items_textalign + \scratchwidth\d_typo_items_text_width + \useitemsstyleandcolor\c!textstyle\c!textcolor + \typo_items_make{\processcommalist[#1]\typo_items_item}}% + \ifx\p_typo_items_symbol\empty + \setbox\b_typo_items_symbols\emptyhbox + \else + \setbox\b_typo_items_symbols\hbox + {\c_typo_items_m\zerocount + \let\m_typo_items_align\p_typo_items_align + \scratchwidth\d_typo_items_symbol_width + \useitemsstyleandcolor\c!style\c!color + \typo_items_make{\dorecurse\c_typo_items_n{\typo_items_item{\strut\m_typo_items_symbol\recurselevel}}}}% + \fi} + +% alternatives: + +\defineitems[\v!top][\c!width=\d_typo_items_text_width,\c!textalign=\itemsparameter\c!align] + +\setvalue{\??itemsalternatives\v!top}#1% + {\let\typo_items_make\typo_items_make_horizontal + \let\typo_items_item\typo_items_item_horizontal + \typo_items_construct_items_boxes{#1}% + \noindent\vbox\bgroup + \forgetall + \ifvoid\b_typo_items_symbols \else + \box\b_typo_items_symbols + \itemsparameter\c!inbetween + \nointerlineskip + \fi + \box\b_typo_items_texts\ + \egroup} + +\defineitems[\v!bottom][\c!width=\d_typo_items_text_width,\c!textalign=\itemsparameter\c!align] + +\setvalue{\??itemsalternatives\v!bottom}#1% + {\let\typo_items_make\typo_items_make_horizontal + \let\typo_items_item\typo_items_item_horizontal + \typo_items_construct_items_boxes{#1}% + \noindent\vbox\bgroup + \forgetall + \box\b_typo_items_texts + \ifvoid\b_typo_items_symbols \else + \itemsparameter\c!inbetween + \nointerlineskip + \box\b_typo_items_symbols + \fi + \egroup} + +\defineitems[\v!inmargin][\c!width=1.5\emwidth,\c!align=\v!flushright,\c!distance=\leftmargindistance] + +\setvalue{\??itemsalternatives\v!inmargin}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \ifvoid\b_typo_items_symbols \else + \llap{\box\b_typo_items_symbols\hskip\d_typo_items_distance}% + \fi + \box\b_typo_items_texts + \egroup} + +\defineitems[\v!left][\c!width=1.5\emwidth,\c!align=\v!flushleft] + +\setvalue{\??itemsalternatives\v!left}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \advance\d_typo_items_text_width-\dimexpr\d_typo_items_symbol_width+\d_typo_items_distance\relax + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \ifvoid\b_typo_items_symbols \else + \box\b_typo_items_symbols + \kern\d_typo_items_distance + \fi + \box\b_typo_items_texts + \egroup} + +\defineitems[\v!right][\c!width=1.5\emwidth,\c!align=\v!flushright] + +\setvalue{\??itemsalternatives\v!right}#1% + {\let\typo_items_make\typo_items_make_vertical + \let\typo_items_item\typo_items_item_vertical + \advance\d_typo_items_text_width-\dimexpr\d_typo_items_symbol_width+\d_typo_items_distance\relax + \typo_items_construct_items_boxes{#1}% + \noindent\hbox\bgroup + \box\b_typo_items_texts + \ifvoid\b_typo_items_symbols \else + \kern\d_typo_items_distance + \box\b_typo_items_symbols + \fi + \egroup} + +\protect \endinput diff --git a/tex/context/base/typo-txt.mkvi b/tex/context/base/typo-txt.mkvi index f2859b58f..0e926ed2c 100644 --- a/tex/context/base/typo-txt.mkvi +++ b/tex/context/base/typo-txt.mkvi @@ -2,7 +2,7 @@ %D [ file=typo-txt, %D version=2011.10.27, %D title=\CONTEXT\ Typesetting Macros, -%D subtitle=Texts, +%D subtitle=Text Hacks, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] @@ -13,12 +13,63 @@ %D This module replaces the by now rather old supp-fun module. +\writestatus{loading}{ConTeXt Typesetting Macros / Text Hacks} + \unprotect -%D \NormalizeFontHeight \name {sample text} {height} {font} -%D \NormalizeFontWidth \name {sample text} {width} {font} -%D \NormalizeTextHeight {font} {height} {text} -%D \NormalizeTextWidth {font} {width} {text} +\registerctxluafile{typo-txt}{1.001} + +%D \macros +%D {normalizefontheight,normalizefontwidth,normalizedfontsize} +%D +%D Next we introduce some font manipulation macros. When we +%D want to typeset some text spread in a well defined area, it +%D can be considered bad practice to manipulate character and +%D word spacing. In such situations the next few macros can be +%D of help: +%D +%D \starttyping +%D \normalizefontheight \name {sample text} {height} {font} +%D \normalizefontwidth \name {sample text} {width} {font} +%D \stoptyping +%D +%D Consider for instance: +%D +%D \startbuffer[a] +%D \NormalizeFontHeight \TempFont {X} {2\baselineskip} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont To Be Or Not To Be} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This shows up as: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The horizontal counterpart is: +%D +%D \startbuffer[a] +%D \NormalizeFontWidth \TempFont {This Line Fits} {\hsize} {Serif} +%D \stopbuffer +%D +%D \startbuffer[b] +%D \ruledhbox{\TempFont This Line Fits} +%D \stopbuffer +%D +%D \typebuffer[a,b] \getbuffer[a] +%D +%D This gives: +%D +%D \startlinecorrection +%D \ruledhbox{\getbuffer[b]} +%D \stoplinecorrection +%D +%D The calculated font scale is avaliable in \type {\normalizedfontsize}. \newbox\b_typo_normalizers @@ -26,14 +77,14 @@ {\dimexpr\ifdim#1\b_typo_normalizers=\zeropoint \bodyfontsize \else - \cldcontext{\number\dimexpr10pt\relax*\number\dimexpr#size\relax/\number#axis\b_typo_normalizers}\scaledpoint + \luaexpr{\number\dimexpr10pt\relax*\number\dimexpr#size\relax/\number#axis\b_typo_normalizers}\scaledpoint \fi\relax} \def\typo_normalizers_font_at_size#axis#cs#text#size#font% avoid overflow by using lua {\begingroup \setbox\b_typo_normalizers\hbox{\definedfont[#font at 10pt]\settrialtypesetting#text}% - \normalexpanded{\endgroup\edef\noexpand\TheNormalizedFontSize{\the\typo_normalizers_size{#axis}{#size}}}% - \edef#cs{\noexpand\definedfont[#font at \TheNormalizedFontSize]}} + \normalexpanded{\endgroup\edef\noexpand\normalizedfontsize{\the\typo_normalizers_size{#axis}{#size}}}% + \definefont[\strippedcsname#cs][#font at \normalizedfontsize]} \unexpanded\def\typo_normalizers_text_at_size#axis#font#size#text% {\dontleavehmode @@ -42,30 +93,105 @@ \definedfont[#font at \the\typo_normalizers_size{#axis}{#size}]#text% \endgroup} -\let\TheNormalizedFontSize\!!zeropoint +\def\normalizedfontsize{\bodyfontsize} + +\unexpanded\def\normalizetextwidth {\typo_normalizers_text_at_size\wd} +\unexpanded\def\normalizetextheight{\typo_normalizers_text_at_size\ht} +\unexpanded\def\normalizetextdepth {\typo_normalizers_text_at_size\dp} +\unexpanded\def\normalizetextline {\typo_normalizers_text_at_size\htdp} + +\unexpanded\def\normalizefontwidth {\typo_normalizers_font_at_size\wd} +\unexpanded\def\normalizefontheight{\typo_normalizers_font_at_size\ht} +\unexpanded\def\normalizefontdepth {\typo_normalizers_font_at_size\dp} +\unexpanded\def\normalizefontline {\typo_normalizers_font_at_size\htdp} -%D Traditionally we use UpperCasedNames for this kind of -%D functionality. +\unexpanded\def\widthspanningtext #text#width#specification{\hbox{\normalizefontwidth \temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\heightspanningtext#text#width#specification{\hbox{\normalizefontheight\temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\depthspanningtext #text#width#specification{\hbox{\normalizefontdepth \temp{#text}{#width}{#specification}\temp#text}} +\unexpanded\def\linespanningtext #text#width#specification{\hbox{\normalizefontline \temp{#text}{#width}{#specification}\temp#text}} -\unexpanded\def\NormalizeFontHeight{\typo_normalizers_font_at_size\ht} -\unexpanded\def\NormalizeFontWidth {\typo_normalizers_font_at_size\wd} +%D Traditionally we use UpperCasedNames for this kind of functionality. -\unexpanded\def\NormalizeTextHeight{\typo_normalizers_text_at_size\ht} -\unexpanded\def\NormalizeTextWidth {\typo_normalizers_text_at_size\wd} +\let\NormalizeFontHeight \normalizefontheight +\let\NormalizeFontWidth \normalizefontwidth +\let\NormalizeTextHeight \normalizetextheight +\let\NormalizeTextWidth \normalizetextwidth -\unexpanded\def\WidthSpanningText#text#width#font% compatibility macro - {\hbox{\NormalizeFontWidth\temp{#text}{#width}{#font}\temp\the\everydefinedfont#1}} +\let\WidthSpanningText \widthspanningtext +\def\TheNormalizedFontSize{\normalizedfontsize} + +%D \macros +%D {vulgarfraction} +%D +%D This code is moved from \type {cor-mis.mkiv}. We show three versions. First +%D the simple one using \type {\low} and \type {high}: +%D %D \startbuffer -%D \NormalizeFontWidth \MyFontName {sample text} {10cm} {Serif*default} +%D \def\vfrac#1#2% +%D {\hbox{\high{\tx#1\kern-.25em}/\low{\kern-.25em\tx#2}}} +%D +%D test \vfrac{1}{2} test \vfrac{123}{456} test +%D \stopbuffer +%D +%D \typebuffer {\showmakeup\getbuffer} +%D +%D A better way to handle the kerning is the following, here we kind of assume +%D that tye slash is symmetrical and has nearly zero width. %D -%D \ruledhbox{\MyFontName sample text} -%D \blank -%D \blackrule[width=10cm] -%D \blank -%D \ruledhbox{\NormalizeTextWidth {Serif*default} {10cm} {sample text}} +%D \startbuffer +%D \def\vfract#1#2% +%D {\hbox{\high{\tx#1}\hbox to \zeropoint{\hss/\hss}\low{\tx#2}}} %D \stopbuffer %D -%D \typebuffer \getbuffer +%D \typebuffer {\showmakeup\getbuffer} +%D +%D The third and best alternative is the following: +%D +%D {\showmakeup\getbuffer}\crlf\getbuffer +%D +%D This time we measure the height of the \type {/} and shift over the maximum +%D height and depths of this character and the fractional digits (we use 57 as +%D sample). Here we combine all methods in one macros. + +\setnewconstant\vulgarfractionmethod\plusthree + +\definehspace[\v!vulgarfraction][.25em] % [.15em] +\definesymbol[\v!vulgarfraction][/] % [\raise.2ex\hbox{/}] + +\unexpanded\def\vulgarfraction#1#2% + {\dontleavehmode + \hbox + {\def\vulgarfraction{vulgarfraction}% + \ifcase\vulgarfractionmethod + #1\symbol[\v!vulgarfraction]#2% + \or + \high{\tx#1\kern-\hspaceamount\empty\v!vulgarfraction}% + \symbol[\vulgarfraction]% + \low {\kern-\hspaceamount\empty\v!vulgarfraction\tx#2}% + \or + \high{\tx#1}% + \hbox to \zeropoint{\hss\symbol[\v!vulgarfraction]\hss}% + \low{\tx#2}% + \or + \setbox0\hbox{\symbol[\vulgarfraction]}% + \setbox2\hbox{\txx57}% + \raise\ht0\hbox{\lower\ht2\hbox{\txx#1}}% + \hbox to \zeropoint{\hss\symbol[\v!vulgarfraction]\hss}% + \lower\dp0\hbox{\raise\dp2\hbox{\txx#2}}% + \fi}} + +\ifdefined\vfrac \else \let\vfrac\vulgarfraction \fi + +%D \starttabulate[|l|l|] +%D \HL +%D \NC \bf method \NC \bf visualization \NC\NR +%D \HL +%D \NC 0 \NC \vulgarfractionmethod0 \vulgarfraction{1}{2} \NC\NR +%D \NC 1 \NC \vulgarfractionmethod1 \vulgarfraction{1}{2} \NC\NR +%D \NC 2 \NC \vulgarfractionmethod2 \vulgarfraction{1}{2} \NC\NR +%D \NC 3 \NC \vulgarfractionmethod3 \vulgarfraction{1}{2} \NC\NR +%D \HL +%D \stoptabulate \protect \endinput diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 0037577c6..609b93658 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 06/28/12 10:00:12 +-- merge date : 06/30/12 12:32:51 do -- begin closure to overcome local limits and interference -- cgit v1.2.3