pack-cut.mkiv /size: 5599 b    last modification: 2023-12-21 09:44
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% not grouped !
106  {\d_pack_cutmarks_height\ht#1%
107   \d_pack_cutmarks_depth \dp#1%
108   \d_pack_cutmarks_width \wd#1%
109   \setbox#1\hpack
110     {\dontcomplain
111      \forgetall
112      \boxmaxdepth\maxdimen
113      \offinterlineskip
114      \scratchdimen\dimexpr\cutmarklength/2\relax
115      \hsize\d_pack_cutmarks_width
116      \setbox\scratchbox\vpack
117        {\setbox\scratchbox\hpack{\horizontalcuts}%
118         \scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
119         \tlap{\copy\scratchbox\vskip\scratchskip}%
120         \hpack to \d_pack_cutmarks_width
121           {\scratchskip\ifx\cutmarkhoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkhoffset\fi
122            \setbox\scratchbox\hpack{\verticalcuts}%
123            \llap{\copy\scratchbox\hskip\scratchskip}%
124            \ifdim\d_pack_cutmarks_depth=\zeropoint
125              \hfill
126            \else
127              \bgroup
128              \setbox\scratchbox\hpack{\baselinecuts}%
129              \llap{\copy\scratchbox\hskip\scratchskip}%
130              \hfill
131              \rlap{\hskip\scratchskip\copy\scratchbox}%
132              \egroup
133            \fi
134            \rlap{\hskip\scratchskip\copy\scratchbox}}%
135         \blap{\vskip\scratchskip\copy\scratchbox}}%
136      \ht\scratchbox\d_pack_cutmarks_height
137      \dp\scratchbox\d_pack_cutmarks_depth
138      \wd\scratchbox\zeropoint
139      \startcolor[\defaulttextcolor]%
140      \box\scratchbox
141      \ifx\cutmarksymbol\relax \else
142        \setbox\scratchbox\vpack
143          {\scratchskip\ifx\cutmarkvoffset\empty\cutmarkoffset\scratchdimen\else\cutmarkvoffset\fi
144           \vskip-\dimexpr\scratchskip+\cutmarklength\relax
145           \hpack{\cutmarksymbols\cutmarktoptext}%
146           \vskip\dimexpr\scratchskip+\d_pack_cutmarks_height+\d_pack_cutmarks_depth+\scratchskip\relax
147           \hpack{\cutmarksymbols\cutmarkbottomtext}}%
148        \ht\scratchbox\d_pack_cutmarks_height
149        \dp\scratchbox\d_pack_cutmarks_depth
150        \wd\scratchbox\zeropoint
151        \box\scratchbox
152      \fi
153      \stopcolor
154      \box#1}%
155   \wd#1\d_pack_cutmarks_width
156   \ht#1\d_pack_cutmarks_height
157   \dp#1\d_pack_cutmarks_depth}
158
159\unexpanded\def\cuthbox{\hpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\hbox}
160\unexpanded\def\cutvbox{\vpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vbox}
161\unexpanded\def\cutvtop{\tpack\bgroup\dowithnextbox{\makecutbox\nextbox\flushnextbox\egroup}\vtop}
162
163\protect \endinput
164