diff options
Diffstat (limited to 'tex/context/base/supp-fun.tex')
-rw-r--r-- | tex/context/base/supp-fun.tex | 294 |
1 files changed, 147 insertions, 147 deletions
diff --git a/tex/context/base/supp-fun.tex b/tex/context/base/supp-fun.tex index 4cbdf359f..2da73e625 100644 --- a/tex/context/base/supp-fun.tex +++ b/tex/context/base/supp-fun.tex @@ -8,15 +8,15 @@ %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. +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. \unprotect -%D This module implements some typographics tricks that can +%D This module implements some typographics tricks that can %D be fun when designing document layouts. The examples use %D macros that are typical to \CONTEXT, but non \CONTEXT\ -%D users can use the drop caps and first line treatment +%D users can use the drop caps and first line treatment %D macros without problems. This module will be extended %D when the need for more of such tricks arises. @@ -30,17 +30,17 @@ %D \macros %D {DroppedCaps, DroppedString, DroppedIndent, DroppedLines} -%D +%D %D \startbuffer -%D \DroppedCaps -%D {\color[green]} {cmbx12} -%D {2.2\baselineskip} {2pt} {\baselineskip} {2} +%D \DroppedCaps +%D {\color[green]} {cmbx12} +%D {2.2\baselineskip} {2pt} {\baselineskip} {2} %D Let's start %D \stopbuffer %D %D \haalbuffer with dropped caps, those blown up first %D characters of a paragraph. It's hard to implement a general -%D mechanism that suits all situations, but dropped caps are so +%D mechanism that suits all situations, but dropped caps are so %D seldomly used that we can permit ourselves a rather user %D unfriendly implementation. %D @@ -57,9 +57,9 @@ %D natural position in the encoding vector. %D %D \startbuffer -%D \DroppedCaps -%D {\color[red]} {cmbx12} -%D {\baselineskip} {0pt} {0pt} {1} +%D \DroppedCaps +%D {\color[red]} {cmbx12} +%D {\baselineskip} {0pt} {0pt} {1} %D This simple %D \stopbuffer %D @@ -69,26 +69,26 @@ %D \typebuffer %D %D \startbuffer -%D \DroppedCaps -%D {\color[red]} {cmbx12} -%D {2\baselineskip} {0pt} {\baselineskip} {2} -%D Is this ugly +%D \DroppedCaps +%D {\color[red]} {cmbx12} +%D {2\baselineskip} {0pt} {\baselineskip} {2} +%D Is this ugly %D \stopbuffer -%D -%D \haalbuffer example the third argument tells -%D this macro that we want a dropped capital scaled to the -%D baseline distance. The two zero point arguments are the +%D +%D \haalbuffer example the third argument tells +%D this macro that we want a dropped capital scaled to the +%D baseline distance. The two zero point arguments are the %D horizontal and vertical offsets and the last arguments -%D determines the hanging indentation. In this paragraph we -%D set the height to two times the baselinedistance and use -%D two hanging lines: -%D +%D determines the hanging indentation. In this paragraph we +%D set the height to two times the baselinedistance and use +%D two hanging lines: +%D %D \typebuffer -%D +%D %D Here, the first character is moved down one baseline. Here %D we also see why the horizontal offset is important. The %D first example (showing the~L) sets this to a few points and -%D also used a slightly larger height. +%D also used a slightly larger height. %D %D Of course common users (typist) are not supposed to see this %D kind of fuzzy definitions, but fortunately \TEX\ permits us @@ -97,15 +97,15 @@ %D %D \startbuffer %D \def\MyDroppedCaps% -%D {\DroppedCaps -%D {\color[green]} {cmbx12} +%D {\DroppedCaps +%D {\color[green]} {cmbx12} %D {5\baselineskip} {3pt} {3\baselineskip} {4}} %D %D \MyDroppedCaps The implementation %D \stopbuffer -%D +%D %D \typebuffer -%D +%D %D \haalbuffer of the general macro is rather simple and only %D depends on the arguments given and the dimensions of the %D strut box. We explicitly load the font, which is no problem @@ -113,16 +113,16 @@ %D combined some arguments, like the height, vertical offset %D and the number of lines, but the current implementation %D proved to be the most flexible. One should be aware of the -%D fact that the offsets depend on the design of the glyphs -%D used. +%D fact that the offsets depend on the design of the glyphs +%D used. \let\DroppedIndent\!!zeropoint \def\DroppedLines{0} \def\DroppedString% {ABCDEFGHIJKLMNOPQRSTUVWXYZ} -% \def\DroppedCaps#1#2#3#4#5#6#7% -% {\ExpandBothAfter\doifinstringelse{#7}{\DroppedString} % +% \def\DroppedCaps#1#2#3#4#5#6#7% +% {\ExpandBothAfter\doifinstringelse{#7}{\DroppedString} % % {\ifvmode % this one is \EveryPar save, precede by \par if needed % \vskip#6\baselineskip % \penalty-200 @@ -149,7 +149,7 @@ % \hskip-\DroppedIndent % \vbox{\forgetall\box0}% % \nobreak -% \ignorespaces} % Could be a one character word ! +% \ignorespaces} % Could be a one character word ! % {\edef\DroppedIndent{0pt}% % \edef\DroppedLines {\number\maxdimen}% % #7}} @@ -196,10 +196,10 @@ % \globaldropcaps\edef\DroppedLines{\number\maxdimen}% % \globaldropcaps\chardef\DroppedStatus3 % \def\next{#7}}% -% \let\globaldropcaps\global +% \let\globaldropcaps\global % \next} -\chardef\DropMode=0 % 1 == marginhang +\chardef\DropMode=0 % 1 == marginhang \def\DroppedCaps#1#2#3#4#5#6#7% does not yet handle accented chars {\convertargument #7\to\asciia @@ -248,20 +248,20 @@ \globaldropcaps\edef\DroppedLines{\number\maxdimen}% \globaldropcaps\chardef\DroppedStatus3 \def\next{#7}}% - \let\globaldropcaps\global + \let\globaldropcaps\global \next} %D Before we go to the next topic, we summarize this command: %D %D \starttypen -%D \DroppedCaps -%D {command} {font} +%D \DroppedCaps +%D {command} {font} %D {height} {hoffset} {voffset} {lines} %D \stoptypen -%D +%D %D Sometimes you need to make sure that the global settings are -%D kept local, as in: -%D +%D kept local, as in: +%D % %D \startbuffer % %D \defineparagraphs[SomePar][n=2,rule=on] % %D \setupparagraphs [SomePar][1][width=.5\textwidth] @@ -270,26 +270,26 @@ %D \definieeralineas[SomePar][n=2,rule=on] %D \stelalineasin [SomePar][1][width=.5\textwidth] %D \stelalineasin [SomePar][2][width=.5\textwidth] -%D +%D %D \startSomePar %D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need %D to explicitly keep the hanging indentation local, like it or -%D not. +%D not. %D \SomePar %D \localdropcaps\NiceDroppedCaps{}{cmr12}{0pt}{2}Here we need %D to explicitly keep the hanging indentation local, like it or -%D not. +%D not. %D \stopSomePar %D \stopbuffer -%D +%D %D \typebuffer \getbuffer -%D \macros +%D \macros %D {AutoDroppedCaps, CheckDroppedCaps} %D %D {\em To be documented.} -% example usage +% example usage % % \def\bpar{\ifvmode\CheckDroppedCaps\fi} % \def\epar{\ifhmode\par\fi\CheckDroppedCaps} @@ -307,17 +307,17 @@ \EveryPar{\doAutoDroppedCaps}} \let\AutoDroppedNext\relax - + \def\doAutoDroppedCaps {\ifcase\DroppedStatus % done - \let\next\relax + \let\next\relax \or % starting - % \ifnum\lastprevgraf>0 % tricky, probably a wrong par + % \ifnum\lastprevgraf>0 % tricky, probably a wrong par % \globaldropcaps\chardef\DroppedStatus=3 % and inhibits dropped % \let\next\relax % caps after titles and more than once - % \else % so let's nill this rubishly code fragment + % \else % so let's nill this rubishly code fragment \def\next{\NiceDroppedCaps{}{\@@dcfont}{.125em}{\@@dcn}}% - % \fi % and hope for the best + % \fi % and hope for the best \or % doing \global\advance\droppedlines \lastprevgraf \ifnum\droppedlines=\zerocount @@ -344,21 +344,21 @@ \fi \next} -%D \macros +%D \macros %D {LineDroppedCaps, NiceDroppedCaps} %D -%D To save definitions, we also provide: +%D To save definitions, we also provide: %D %D \starttypen %D \LineDroppedCaps {command} {font} {hoffset} {lines} %D \NiceDroppedCaps {command} {font} {hoffset} {lines} %D \stoptypen %D -%D The first command scales the font to the exact height, while -%D the second command scales the font to a nice 2.5 times the -%D line height, a value that gives a pleasant grayness. +%D The first command scales the font to the exact height, while +%D the second command scales the font to a nice 2.5 times the +%D line height, a value that gives a pleasant grayness. -\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines +\def\DoLineDroppedCaps#1#2#3#4#5% compensation command font offset lines {\scratchcounter#5% \advance\scratchcounter \minusone \scratchdimen\scratchcounter\baselineskip @@ -398,15 +398,15 @@ %D \haalbuffer %D %D \typebuffer -%D +%D %D Before we explain the third and fourth argument, we show the -%D implementation. Those who know a bit about the way \TEX\ +%D implementation. Those who know a bit about the way \TEX\ %D treats tokens, will probably see in one glance that this %D alternative works all right for most text||only situations %D in which there is enough text available for the first line, %D but that more complicated things will blow. One has to live %D with that. A workaround is rather trivial but obscures the -%D principles used. +%D principles used. \def\TreatFirstLine#1#2#3#4% before, after, first, next {\leavevmode @@ -429,7 +429,7 @@ \@EA\grabfirstline \else\ifdim\wd2>\hsize \hbox to \hsize{\strut\unhbox0}#2\egroup - \break##1\ + \break##1\ \egroup \else \setbox0\box2 @@ -444,19 +444,19 @@ %D \getrandomfloat\FunnyB{0}{1}% %D \definecolor[FunnyColor][r=\FunnyR,g=\FunnyG,b=\FunnyB]% %D \color[FunnyColor]} -%D +%D %D \TreatFirstLine {\bf} {} {\FunnyCommand} {\FunnyCommand} -%D The third and fourth argument can be used to gain special +%D The third and fourth argument can be used to gain special %D effects on the individual words. Of course one needs ... %D \stopbuffer -%D -%D \haalbuffer -%D to know a bit more about the macro package used to get real -%D nice effects, but this example probably demonstrates the -%D principles well. -%D +%D +%D \haalbuffer +%D to know a bit more about the macro package used to get real +%D nice effects, but this example probably demonstrates the +%D principles well. +%D %D \typebuffer -%D +%D %D Like in dropped caps case, one can hide such treatments in a %D macro, like: %D @@ -465,38 +465,38 @@ %D {\TreatFirstLine{\bf}{}{\FunnyCommand}{\FunnyCommand}} %D \stoptypen -%D \macros +%D \macros %D {reshapebox} -%D -%D \startbuffer +%D +%D \startbuffer %D \beginofshapebox -%D When using \CONTEXT, one can also apply this funny command -%D to whole lines by using the reshape mechanism. Describing -%D this interesting mechanism falls outside the scope of this -%D module, so we only show the trick. This is an example of -%D low level \CONTEXT\ functionality: it's all there, and it's -%D stable, but not entirely meant for novice users. +%D When using \CONTEXT, one can also apply this funny command +%D to whole lines by using the reshape mechanism. Describing +%D this interesting mechanism falls outside the scope of this +%D module, so we only show the trick. This is an example of +%D low level \CONTEXT\ functionality: it's all there, and it's +%D stable, but not entirely meant for novice users. %D \endofshapebox -%D +%D %D \reshapebox{\FunnyCommand{\box\shapebox}} \flushshapebox %D \stopbuffer -%D +%D %D \haalbuffer -%D +%D %D \typebuffer %D -%D This mechanism permits hyphenation and therefore gives -%D better results than the previously discussed macro -%D \type{\TreatFirstLine}. +%D This mechanism permits hyphenation and therefore gives +%D better results than the previously discussed macro +%D \type{\TreatFirstLine}. %D \macros %D {TreatFirstCharacter} %D %D \startbuffer -%D \TreatFirstCharacter{\bf\color[green]} Just to be +%D \TreatFirstCharacter{\bf\color[green]} Just to be %D \stopbuffer %D -%D \haalbuffer complete we also offer a very simple one +%D \haalbuffer complete we also offer a very simple one %D character alternative, that is not that hard to understand: \def\TreatFirstCharacter#1#2% command, character @@ -523,9 +523,9 @@ %D \startbuffer %D \StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand} %D \stopbuffer -%D +%D %D Such a stack looks like: -%D +%D %D \startregelcorrectie %D \hbox to \hsize %D {$\hss\bfd @@ -538,7 +538,7 @@ %D \vcenter{\StackCharacters{CONTEXT}{}{\vskip.2ex}{\FunnyCommand}} %D \hss$} %D \stopregelcorrectie -%D +%D %D and is typeset by saying: %D %D \typebuffer @@ -560,18 +560,18 @@ %D \stoptypen %D %D \startbuffer[a] -%D \processtokens -%D {\hbox to .5\hsize\bgroup} {\hfill} +%D \processtokens +%D {\hbox to .5\hsize\bgroup} {\hfill} %D {\egroup} {\space} {LET'S HAVE} %D \stopbuffer -%D +%D %D \startbuffer[b] -%D \processtokens -%D {\vbox\bgroup\raggedcenter\hsize1em} +%D \processtokens +%D {\vbox\bgroup\raggedcenter\hsize1em} %D {\vskip.25ex} {\egroup} {\strut} {FUN} %D \stopbuffer %D -%D This macro is able to typeset: +%D This macro is able to typeset: %D %D \leavevmode\hbox to \hsize %D {$\hfil\hfil @@ -586,24 +586,24 @@ %D \typebuffer[b] %D \macros -%D {NormalizeFontHeight, NormalizeFontWidth, +%D {NormalizeFontHeight, NormalizeFontWidth, %D TheNormalizedFontSize} %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 of help: +%D %D \starttypen %D \NormalizeFontHeight \name {sample text} {height} {font} %D \NormalizeFontWidth \name {sample text} {width} {font} %D \stoptypen -%D +%D %D These are implemented using an auxilliary macro: \def\NormalizeFontHeight{\NormalizeFontSize\ht} -\def\NormalizeFontWidth {\NormalizeFontSize\wd} +\def\NormalizeFontWidth {\NormalizeFontSize\wd} % \def\NormalizeFontSize#1#2#3#4#5% % {\bgroup @@ -624,9 +624,9 @@ % \egroup % \expandafter\font\expandafter#2\fontname\font\relax} % -% the familiar struggle with accuracy forces us to use: +% the familiar struggle with accuracy forces us to use: -\def\NormalizeFontSize#1#2#3#4#5% +\def\NormalizeFontSize#1#2#3#4#5% {\bgroup \dimen0=#4% #4 can be \ht0 or so \setbox0\hbox{\definedfont[#5 at 5pt]#3}% 10pt @@ -646,62 +646,62 @@ \egroup \expandafter\font\expandafter#2\fontname\font\relax} -%D Afterwards, we have access to the calculated size by: +%D Afterwards, we have access to the calculated size by: \let\TheNormalizedFontSize\!!zeropoint -%D Extra: +%D Extra: -\def\WidthSpanningText#1#2#3% text width font +\def\WidthSpanningText#1#2#3% text width font {\hbox{\NormalizeFontWidth\temp{#1}{#2}{#3}\temp\the\everydefinedfont#1}} %D Consider for instance: -%D +%D %D \startbuffer %D \NormalizeFontHeight \tmp {X} {2\baselineskip} {cmr10} -%D +%D %D {\tmp To Be Or Not To Be} %D \stopbuffer -%D +%D %D \typebuffer -%D +%D %D This shows up as (we also show the baselines): -%D +%D %D {\showbaselines\haalbuffer} -%D +%D %D The horizontal counterpart is: -%D +%D %D \startbuffer %D \NormalizeFontWidth \tmp {This Line Fits} {\hsize} {cmr10} -%D +%D %D \hbox{\tmp This Line Fits} %D \stopbuffer -%D +%D %D \typebuffer -%D -%D The calculated font scale is avaliable in the macro -%D \type{\NormalizedFontSize}. +%D +%D The calculated font scale is avaliable in the macro +%D \type{\NormalizedFontSize}. %D %D \startregelcorrectie %D \ruledhbox{\haalbuffer} %D \stopregelcorrectie %D -%D One can of course combine these macros with the ones +%D One can of course combine these macros with the ones %D described earlier, like in: -%D +%D %D \starttypen %D \NormalizeFontHeight {text} \DroppedFont {2\baselineskip} {cmbx12} -%D +%D %D \def\NicelyDroppedCaps -%D {\DroppedCaps -%D {\kleur[groen]} -%D {\DroppedFont} -%D {2pt} -%D {\baselineskip} +%D {\DroppedCaps +%D {\kleur[groen]} +%D {\DroppedFont} +%D {2pt} +%D {\baselineskip} %D {2}} %D \stoptypen %D -%D It's up to the reader to test this one. +%D It's up to the reader to test this one. \unexpanded\def\FirstNCharacters#1#2% \FirstNCharacters{3}{fr{\"o}beln} {\bgroup @@ -714,15 +714,15 @@ \handletokens#2\with\docommando \egroup} -%D \macros +%D \macros %D {FittingText} %D -%D First used in Pascal (demo-bbv): -%D +%D First used in Pascal (demo-bbv): +%D %D \startbuffer %D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} %D {\veryraggedright -%D \hangindent1em\hangafter1\relax +%D \hangindent1em\hangafter1\relax %D \begstrut \dorecurse{8}{Bram Marta }\unskip \endstrut}} %D %D \ruledvbox{\FittingText{3cm}{1cm}{Serif}{24pt}{1pt}{1} @@ -735,19 +735,19 @@ %D \getbuffer %D \stoplinecorrection -% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text +% #1 width #2 height #3 font #4 size #5 step #6 interlinie #7 text -\long\def\FittingText#1#2#3#4#5#6#7% +\long\def\FittingText#1#2#3#4#5#6#7% {\bgroup \forgetall \dontcomplain \setuptolerance[\v!zeersoepel]% == \tolerance4500 - \hsize#1% + \hsize#1% \def\\{\softbreak}% \!!heighta#4% \!!heightb#2% \doloop - {\ifdim\!!heighta>\!!onepoint + {\ifdim\!!heighta>\onepoint \expanded{\definefont[\s!dummy][#3 at \the\!!heighta][\c!interlinie=#6]}% \getvalue\s!dummy \setbox\scratchbox\vbox{#7\endgraf}% @@ -760,14 +760,14 @@ \global\dimen1\hsize \reshapebox {\setbox\shapebox\hbox{\unhbox\shapebox}% - \ifdim\wd\shapebox>\dimen1 + \ifdim\wd\shapebox>\dimen1 \global\dimen1\wd\shapebox \fi}% - \ifdim\dimen1>\hsize + \ifdim\dimen1>\hsize \advance\!!heighta-#5% \else \exitloop - \fi + \fi \fi \else \exitloop @@ -776,25 +776,25 @@ \unvbox\scratchbox \egroup} -%D New: +%D New: -% \font width gap font spec text +% \font width gap font spec text -\def\NormalizeFontWidthSpread#1#2#3#4#5#6% +\def\NormalizeFontWidthSpread#1#2#3#4#5#6% {\global\setfalse\NFSpread \scratchdimen#3% \scratchdimen-.5\scratchdimen \advance\scratchdimen#2\relax - \NormalizeFontWidth + \NormalizeFontWidth #1% {\def\+{\global\settrue\NFSpread\gobbleuntil\relax}% - \def\\{\gobbleuntil\relax}% newline + \def\\{\gobbleuntil\relax}% newline \setupspacing #6\relax}% {\scratchdimen}% {#4}% \ifconditional\NFSpread - % de gap valt in de binding + % de gap valt in de binding \else \definefont[\strippedcsname#1][#4 #5]% \fi} |