From: Hans Hagen <pragma@wxs.nl>
Subject: Re: baseline alignment
Date: Tue, 10 Aug 2004 00:39:06 +0200 [thread overview]
Message-ID: <4117FD0A.6020509@wxs.nl> (raw)
In-Reply-To: <40FF81F3.1060406@seznam.cz>
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
-----------------------------------------------------------------
next prev parent reply other threads:[~2004-08-09 22:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-22 8:59 Vit Zyka
2004-08-09 22:39 ` Hans Hagen [this message]
2004-09-09 14:36 ` Vit Zyka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4117FD0A.6020509@wxs.nl \
--to=pragma@wxs.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).