diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/core-spa.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/core-spa.mkiv | 369 |
1 files changed, 369 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/core-spa.mkiv b/Master/texmf-dist/tex/context/base/core-spa.mkiv new file mode 100644 index 00000000000..1352e2582bf --- /dev/null +++ b/Master/texmf-dist/tex/context/base/core-spa.mkiv @@ -0,0 +1,369 @@ +%D \module +%D [ file=core-spa, +%D version=1997.03.31, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Spacing, +%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. + +\writestatus{loading}{Context Core Macros / Buffers} + +\unprotect + +% category: +% +% 0 == discard +% 1 == only if larger +% 2 == force even if smaller +% 3 == only take penalty component +% 4 == add to existing skip +% 5 == ignore following skips (== disable) + +% penalty: +% +% larger wins + +% order: +% +% larger wins + +\defineattribute[kern-chars] + +\defineattribute[skip-category] +\defineattribute[skip-penalty] +\defineattribute[skip-order] + +\defineattribute[snap-category] + +\defineattribute[display-math] + +\registerctxluafile{core-spa}{1.001} + +% \start \dosetstretch{.25em} \setuptolerance[tolerant,stretch] \input tufte \endgraf \stop +% \start \dosetstretch{.5em} effe flink doorfietsen \stop + +\def\dosetstretch#1% to be interfaces + {\relax\ifdim#1>\zeropoint + \dosetattribute{kern-chars}{\number\dimexpr#1\relax}% + \else + \doresetattribute{kern-chars}% + \fi} + +\appendtoks\doresetattribute{kern-chars}\to\everyforgetall + +\def\mksetupgridsnapping + {\ctxlua{nodes.setsnapvalue(1,\number\openstrutheight,\number\openstrutdepth)}} + +\def\mkenablegridsnapping + {\dosetattribute{snap-category}{1}% + \topskip\strutht + \offinterlineskip} + +\def\mkdisablegridsnapping + {\doresetattribute{snap-category}% + % reset topskip + \oninterlineskip} + +% experimental spacing +% +% test: oeps {\setcharacterspacing[frenchpunctuation]x: xx \bfd x: xx} oeps: test + +\defineattribute[spacing] + +\newcount \maxcharacterspacingid + +\def\definecharacterspacing[#1]% + {\ifcsname\??ch#1\endcsname \else + \global\advance\maxcharacterspacingid\plusone + \setxvalue{\??ch:#1}{\the\maxcharacterspacingid}% + \fi} + +\def\setupcharacterspacing + {\dotripleargument\dosetupcharacterspacing} + +\def\dosetupcharacterspacing[#1][#2][#3]% + {\ifcsname\??ch:#1\endcsname + \begingroup + \getparameters[\??ch][\c!left=0,\c!right=0,#3]% + \ctxlua{spacings.setspacing(\getvalue{\??ch:#1},\number#2,\@@chleft,\@@chright)}% + \endgroup + \fi} + +\def\setcharacterspacing + {\ctxlua{spacings.enabled=true}% + \gdef\setcharacterspacing[##1]{\dosetattribute{spacing}{\csname\??ch:##1\endcsname}}% + \setcharacterspacing} + +\letvalue{\??ch:\s!reset}\minusone + +\definecharacterspacing [frenchpunctuation] % name may change / unit is em + +\setupcharacterspacing [frenchpunctuation] ["003A] [\c!left =.25] % : +\setupcharacterspacing [frenchpunctuation] ["003B] [\c!left =.25] % ; +\setupcharacterspacing [frenchpunctuation] ["003F] [\c!left =.25] % ? +\setupcharacterspacing [frenchpunctuation] ["0021] [\c!left =.25] % ! +\setupcharacterspacing [frenchpunctuation] ["00AB] [\c!right=.25] % guillemotleft/leftguillemot +\setupcharacterspacing [frenchpunctuation] ["00BB] [\c!left =.25] % guillemotright/rightguillemot + +% more +% +% {\setcharacterkerning[extrakerning]\input davis\relax} + +\defineattribute[kern] + +\newcount \maxcharacterkerningid + +\def\definecharacterkerning + {\dosingleargument\dodefinecharacterkerning} + +\def\dodefinecharacterkerning[#1]% + {\ifcsname\??ck#1\endcsname \else + \global\advance\maxcharacterkerningid\plusone + \setxvalue{\??ck:#1}{\the\maxcharacterkerningid}% + \fi} + +\def\setupcharacterkerning + {\dodoubleargument\dosetupcharacterkerning} + +\def\dosetupcharacterkerning[#1][#2]% + {\ifcsname\??ck:#1\endcsname + \begingroup + \getparameters[\??ck][\c!factor=0,#2]% + \ctxlua{kerns.setspacing(\getvalue{\??ck:#1},\@@ckfactor)}% + \endgroup + \fi} + +\def\setcharacterkerning + {\ctxlua{kerns.enabled=true}% + \gdef\setcharacterkerning[##1]{\dosetattribute{kern}{\csname\??ck:##1\endcsname}}% + \setcharacterkerning} + +\letvalue{\??ck:\s!reset}\minusone + +\definecharacterkerning[extrakerning] + +\setupcharacterkerning[extrakerning][\c!factor=.125] + +% sorry, here: + +% test \WORD{test TEST \TeX} test +% test \word{test TEST \TeX} test +% test \Word{test TEST \TeX} test + +\defineattribute[case] + +\def\setcharactercasing + {\ctxlua{cases.enabled=true}% + \gdef\setcharactercasing[##1]{\dosetattribute{case}{\number##1}}% + \setcharactercasing} + +\def\WORD{\groupedcommand{\setcharactercasing[\plusone ]}{}} +\def\word{\groupedcommand{\setcharactercasing[\plustwo ]}{}} +\def\Word{\groupedcommand{\setcharactercasing[\plusthree]}{}} % \plusfour + +\let\WORDS\WORD +\let\words\word +\let\Words\Word + +% \definestartstop is not yet in available at core-spa time +% +% \startrandomized \input tufte \stoprandomized +% +% \definestartstop[randomized][\c!before=\dosetattribute{case}\plusfour,\c!after=] + +\def\randomizetext{\groupedcommand{\dosetattribute{case}\plusfive}{}} + +% compound stuff (under construction) + +\defineattribute[breakpoint] + +\newbox\breakpointbox + +\definesystemvariable {bp} % BreakPoint + +\exhyphenchar=\minusone % we use a different order then base tex, so we really need this + +\newcount \maxbreakpointsid + +\def\definebreakpoints + {\dosingleargument\dodefinebreakpoints} + +\def\dodefinebreakpoints[#1]% + {\ifcsname\??bp:#1\endcsname \else + \global\advance\maxbreakpointsid\plusone + \setxvalue{\??bp:#1}{\the\maxbreakpointsid}% + \fi} + +\def\installbreakpoint + {\dotripleempty\doinstallbreakpoint} + +% hm, we cannot prebuild lists, font dependent + +\def\doinstallbreakpoint[#1][#2][#3]% + {\ifcsname\??bp:#1\endcsname + \begingroup + \getparameters[\??bp][\c!type=1,\c!nleft=3,\c!nright=3,#3]% + \ctxlua{breakpoints.setreplacement(\csname\??bp:#1\endcsname,#2,\@@bptype,\@@bpnleft,\@@bpnright)}% + \endgroup + \fi} + +\def\setbreakpoints + {\ctxlua{breakpoints.enabled=true}% + \gdef\setbreakpoints[##1]{\dosetattribute{breakpoint}{\csname\??bp:##1\endcsname}}% + \setbreakpoints} + +\letvalue{\??bp:\s!reset}\minusone + +\definebreakpoints[compound] + +\installbreakpoint [compound] [\number`+] [\c!left=3,\c!right=3,\c!type=1] +\installbreakpoint [compound] [\number`-] [\c!left=3,\c!right=3,\c!type=1] +\installbreakpoint [compound] [\number`/] [\c!left=3,\c!right=3,\c!type=1] +\installbreakpoint [compound] [\number`(] [\c!left=3,\c!right=3,\c!type=2] +\installbreakpoint [compound] [\number`)] [\c!left=3,\c!right=3,\c!type=3] + +% \setbreakpoints[compound] + +% experimental code, not yet interfaced: + +% category: +% 0 == discard discard +% 1 == only if larger largest +% 2 == force even if smaller force +% 3 == only take penalty component penalty +% 4 == add to existing skip add +% 5 == disable (ignore following) disable +% 6 == kill whitespace nowhite +% 7 == discard previous goback +% +% penalty: larger wins +% order: larger wins +% category:2,order:5,penalty:10000,skip:value|kw +% +% always -- obsolete +% none -- obsolete +% outer -- obsolete +% reset -- obsolete +% \defineblankmethod [\v!joinedup] {\ifvmode\nointerlineskip\fi} + +% todo, in grid mode: vspacing.fixed = false + +\def\startblankhandling{\begingroup \blankskip \zeropoint} +\def\stopblankhandling {\vskip \blankskip \endgroup} +\def\setblankcategory#1{\dosetattribute{skip-category}{#1}} +\def\setblankorder #1{\dosetattribute{skip-order}{#1}} +\def\setblankpenalty #1{\dosetattribute{skip-penalty}{#1}} +\def\addblankskip#1#2#3{\advance\blankskip#1\dimexpr\ifgridsnapping#3\else#2\fi\relax} +\def\fixedblankskip {\blankskip1\blankskip} +\def\flexibleblankskip {\blankskip1\blankskip\!!plus \skipgluefactor\blankskip\!!minus\skipgluefactor\blankskip} + +\def\definevspacingamount + {\dotripleempty\dodefinevspacingamount} + +\def\dodefinevspacingamount[#1][#2][#3]% + {\ctxlua{vspacing.setskip("#1","\detokenize{#2}","\detokenize{#3}")}} + +\def\definevspacing + {\dodoubleempty\dodefinevspacing} + +\def\dodefinevspacing[#1][#2]% + {\ctxlua{vspacing.setmap("#1","\detokenize{#2}")}} + +\def\vspacing + {\dosingleempty\dovspacing} + +\def\dovspacing[#1]% + {\ctxlua{vspacing.analyse("\iffirstargument#1\else default\fi")}} + +\definevspacingamount[\v!big] [\bigskipamount] [\openlineheight] +\definevspacingamount[\v!medium] [\medskipamount] [.50\openlineheight] +\definevspacingamount[\v!small] [\smallskipamount][.25\openlineheight] +\definevspacingamount[\v!line] [\openlineheight] [\openlineheight] +\definevspacingamount[\v!formula][\medskipamount] [.50\openlineheight] +\definevspacingamount[\v!white] [\parskip] [\openlineheight] + +\definevspacing[\v!halfline][.5*\v!line] +\definevspacing[weak] [order:0] +\definevspacing[strong] [order:100] +\definevspacing[samepage] [penalty:10000] +\definevspacing[\v!force] [category:2] +\definevspacing[\v!disable] [category:5] +\definevspacing[\v!nowhite] [category:6] +\definevspacing[goback] [category:7] +\definevspacing[\v!always] [category:0] + +\definevspacing[\s!default][\v!big] + +% \definevspacing[whatever][4*big] +% \vspacing[2*big,-medium,-3*small,whatever,halfline,order:10,category:4,strong,samepage] +% \vspacing[2*big,category:disable] +% \vspacing[2*big,disable] +% \vspacing[2*big,back] + +\def\enablevspacing{\ctxlua{ + callback.register('vpack_filter', nodes.handle_vbox_spacing) + callback.register('buildpage_filter', nodes.handle_page_spacing) +}} + + +\protect \endinput + +\starttext + +\dorecurse{2}{ + $2^{2^{2^{2}}}$ $2_{2_{2_{2}}}^{2^{2^{2^{2^{2^{2^{2^{2^{2}}}}}}}}}$ + \input tufte \inframed {tufte} + \par +} + +\dorecurse{100} { + + \kern \recurselevel pt + + \vbox { + \endgraf \strut first \endgraf + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{2}\vskip10pt} + \endgraf \strut second \endgraf + } + + \endgraf \strut first \endgraf + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + \endgraf \strut second \endgraf + + {\dosetattribute{skip-category}{0}\vskip10pt} % remove + {\dosetattribute{skip-category}{1}\vskip10pt} % take largest + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\vskip40pt} + {\dosetattribute{skip-category}{1}\dosetattribute{skip-order}{10}\vskip20pt} + {\dosetattribute{skip-category}{4}\dosetattribute{skip-order}{10}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip60pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + {\dosetattribute{skip-category}{0}\vskip10pt} + + third (no break after this) + + {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip10pt} + {\dosetattribute{skip-category}{1}\dosetattribute{skip-penalty}{100000}\vskip20pt} + {\dosetattribute{skip-category}{1}\vskip10pt} + {\dosetattribute{skip-category}{1}\vskip20pt} + + fourth + \vskip10pt + fifth +} + +\stoptext |