pack-cut.mkiv /size: 5607 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=pack-cut, % comes from core-vis/trac-vis
3%D        version=1996.06.01,
4%D          title=\CONTEXT\ Packaging Macros,
5%D       subtitle=Cut boxes,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16%D \macros
17%D   {makecutbox, cuthbox, cutvbox, cutvtop}
18%D
19%D Although mainly used for marking the page, these macros can
20%D also serve local use.
21%D
22%D \startbuffer
23%D \setbox0=\vbox{a real \crlf vertical box} \makecutbox0
24%D \stopbuffer
25%D
26%D \typebuffer
27%D
28%D This marked \type{\vbox} shows up as:
29%D
30%D \startlinecorrection
31%D \getbuffer
32%D \stoplinecorrection
33%D
34%D The alternative macros are used as:
35%D
36%D \startbuffer
37%D \cuthbox{a made cut box}
38%D \stopbuffer
39%D
40%D \typebuffer
41%D
42%D This is typeset as:
43%D
44%D \startlinecorrection
45%D \getbuffer
46%D \stoplinecorrection
47%D
48%D By setting the next macros one can influence the length of
49%D the marks as well as the horizontal and vertical divisions.
50
51\newdimen\d_pack_cutmarks_width
52\newdimen\d_pack_cutmarks_height
53\newdimen\d_pack_cutmarks_depth
54
55\newcount\horizontalcutmarks \horizontalcutmarks \plustwo
56\newcount\verticalcutmarks   \verticalcutmarks   \plustwo
57\newcount\cutmarkoffset      \cutmarkoffset      \plusone
58
59\let\cutmarksymbol       \relax
60\let\cutmarktoptext      \empty
61\let\cutmarkbottomtext   \empty
62\let\cutmarkhoffset      \empty
63\let\cutmarkvoffset      \empty
64\def\cutmarklength       {2\bodyfontsize}
65\def\cutmarkrulethickness{\onepoint}
66
67\unexpanded\def\horizontalcuts
68  {\hpack to \d_pack_cutmarks_width
69     {\dorecurse\horizontalcutmarks{\vrule\s!width\cutmarkrulethickness\s!height\cutmarklength\hfill}%
70      \unskip}}
71
72\unexpanded\def\verticalcuts
73  {\vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax
74     {\hsize\cutmarklength
75      \dorecurse\verticalcutmarks{\vrule\s!height\cutmarkrulethickness\s!width\hsize\vfill}%
76      \unskip}}
77
78\unexpanded\def\baselinecuts
79  {\ifdim\d_pack_cutmarks_depth>\zeropoint
80     \vpack to \dimexpr\d_pack_cutmarks_height+\d_pack_cutmarks_depth\relax
81       {\hsize\dimexpr\cutmarklength/2\relax
82        \vskip\zeropoint\s!plus\d_pack_cutmarks_height
83        \vrule\s!height\cutmarkrulethickness\s!width\hsize
84        \vskip\zeropoint\s!plus\d_pack_cutmarks_depth}%
85   \fi}
86
87\unexpanded\def\cutmarksymbols#1%
88  {\hpack to \d_pack_cutmarks_width
89     {\setbox\scratchbox\hbox to \cutmarklength
90        {\hss\infofont\cutmarksymbol\hss}%
91      \hss
92      \vpack to \cutmarklength
93        {\scratchdimen\dimexpr\cutmarklength/2\relax
94         \scratchskip \ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi
95         \vss
96         \hbox to \d_pack_cutmarks_width
97           {\llap{\copy\scratchbox\hskip\scratchskip}%
98            \hskip\scratchdimen\hss
99            \infofont#1%
100            \hss\hskip\scratchdimen
101            \rlap{\hskip\scratchskip\copy\scratchbox}}%
102         \vss}%
103      \hss}}
104
105\unexpanded\def\makecutbox#1%
106  {\bgroup
107   \d_pack_cutmarks_height\ht#1%
108   \d_pack_cutmarks_depth \dp#1%
109   \d_pack_cutmarks_width \wd#1%
110   \setbox#1\hpack
111     {\dontcomplain
112      \forgetall
113      \boxmaxdepth\maxdimen
114      \offinterlineskip
115      \scratchdimen\dimexpr\cutmarklength/2\relax
116      \hsize\d_pack_cutmarks_width
117      \setbox\scratchbox\vpack
118        {\setbox\scratchbox\hpack{\horizontalcuts}%
119         \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
120         \tlap{\copy\scratchbox\vskip\scratchskip}%
121         \hpack to \d_pack_cutmarks_width
122           {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi
123            \setbox\scratchbox\hpack{\verticalcuts}%
124            \llap{\copy\scratchbox\hskip\scratchskip}%
125            \ifdim\d_pack_cutmarks_depth=\zeropoint
126              \hfill
127            \else
128              \bgroup
129              \setbox\scratchbox\hpack{\baselinecuts}%
130              \llap{\copy\scratchbox\hskip\scratchskip}%
131              \hfill
132              \rlap{\hskip\scratchskip\copy\scratchbox}%
133              \egroup
134            \fi
135            \rlap{\hskip\scratchskip\copy\scratchbox}}%
136         \blap{\vskip\scratchskip\copy\scratchbox}}%
137      \ht\scratchbox\d_pack_cutmarks_height
138      \dp\scratchbox\d_pack_cutmarks_depth
139      \wd\scratchbox\zeropoint
140      \startcolor[\defaulttextcolor]%
141      \box\scratchbox
142      \ifx\cutmarksymbol\relax \else
143        \setbox\scratchbox\vpack
144          {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
145           \vskip-\dimexpr\scratchskip+\cutmarklength\relax
146           \hpack{\cutmarksymbols\cutmarktoptext}%
147           \vskip\dimexpr\scratchskip+\d_pack_cutmarks_height+\d_pack_cutmarks_depth+\scratchskip\relax
148           \hpack{\cutmarksymbols\cutmarkbottomtext}}%
149        \ht\scratchbox\d_pack_cutmarks_height
150        \dp\scratchbox\d_pack_cutmarks_depth
151        \wd\scratchbox\zeropoint
152        \box\scratchbox
153      \fi
154      \stopcolor
155      \box#1}%
156   \wd#1\d_pack_cutmarks_width
157   \ht#1\d_pack_cutmarks_height
158   \dp#1\d_pack_cutmarks_depth
159   \egroup}
160
161\unexpanded\def\cuthbox{\hpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\hbox}
162\unexpanded\def\cutvbox{\vpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vbox}
163\unexpanded\def\cutvtop{\tpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vtop}
164
165\protect \endinput
166