Vit Zyka wrote:
Hallo,
for text positioning in a layer I needed alignment to baseline. I do not known if I missed something but I did not find it in the current ConTeXt. So I did that. Baseline is choosen by capital 'B' in the position parameter. ('B' is adopted from grahicx LaTeX/plain package.)
Also I add \ctop, \ltop, and \rtop in sence of \cbox, \lbox, and rbox, respectively.
I suggest to add the macros to core-box and supp-box.
Vit Zyka
%-------------------------------------------- baseline alignment \setvalue{\??ab\??ab B}{\baselinebox} \setvalue{\??ab\??ab Bl}{\baselineleftbox} \setvalue{\??ab\??ab Bc}{\baselinecenterbox} \setvalue{\??ab\??ab Br}{\baselinerightbox} \setvalue{\??ab\??ab lB}{\leftbaselinebox} \setvalue{\??ab\??ab cB}{\centerbaselinebox} \setvalue{\??ab\??ab rB}{\rightbaselinebox} \def\baselinecenterbox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement-.5\wd0 \global\advance\boxhdisplacement-\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \def\baselineleftbox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement-\wd0 \global\advance\boxhdisplacement-\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \def\baselinerightbox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \let\baselinebox=\baselinecenterbox \let\leftbaselinebox=\baselineleftbox \let\rightbaselinebox=\baselinerightbox
hm, in that case we probably need a few more -) See example below, there is already a grid option; also, keep an eye on topskip (we may need s sl sc sr but who can remember that) I dislike the capital B but the g is available (g from gridline) \unprotect % \v!grid is taken \setvalue{\??ab\??ab m}{\middlebox} \setvalue{\??ab\??ab g}{\baselinemiddlebox} \setvalue{\??ab\??ab gl}{\baselineleftbox} \setvalue{\??ab\??ab gc}{\baselinemiddlebox} \setvalue{\??ab\??ab gr}{\baselinerightbox} \setvalue{\??ab\??ab \v!regel }{\baselinemiddlebox} % \v!grid is taken \setvalue{\??ab\??ab \v!regel\v!links }{\baselineleftbox} \setvalue{\??ab\??ab \v!regel\v!midden}{\baselinemiddlebox} \setvalue{\??ab\??ab \v!regel\v!rechts}{\baselinerightbox} \def\baselinemiddlebox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement-.5\wd0 \global\advance\boxhdisplacement-\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \def\baselineleftbox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement-\wd0 \global\advance\boxhdisplacement-\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \def\baselinerightbox#1% {\normalhbox {\setbox0\placedbox{#1}% \global\boxhdisplacement\boxoffset \global\boxvdisplacement-\boxoffset \boxcursor\hskip\boxhdisplacement\raise-\boxvdisplacement\box0}} \protect \definelayer[text] \setupbackgrounds[text][background=text] \setuplayer[text][width=\textwidth,height=\textheight] \showgrid \starttext \setlayer [text] [location=grid,line=13] {\vtop{\strut \input ward \endstrut}} \setlayer [text] [corner={right,top}, voffset=\topskip, % \topskipgap, location=gl] {\vtop{\begstrut \input ward \endstrut}} x \stoptext i can add that to the kernel if tested
%------------------------------ \ltop, \rtop, \ctop \def\lrctop#1#2#% {\vtop#2\bgroup \let\\=\endgraf \forgetall#1\let\next=} \def\ltop{\lrctop\raggedleft} \def\rtop{\lrctop\raggedright} \def\ctop{\lrctop\raggedcenter}
ok, i've patched/added: \def\lbox{\makelrcbox\normalvbox\raggedleft} \def\cbox{\makelrcbox\normalvbox\raggedcenter} \def\rbox{\makelrcbox\normalvbox\raggedright} \def\ltop{\makelrcbox\normalvtop\raggedleft} \def\ctop{\makelrcbox\normalvtop\raggedcenter} \def\rtop{\makelrcbox\normalvtop\raggedright} \def\makelrcbox#1#2#3#% {#1#3\bgroup \forgetall \let\\=\endgraf #2\let\next=} ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------