[NTG-context] character width

Wolfgang Schuster schuster.wolfgang at googlemail.com
Tue Oct 24 20:45:57 CEST 2006


On Tue, 24 Oct 2006 18:39:22 +0200
Steffen Wolfrum <context at st.estfiles.de> wrote:

> Yes, that's it. Thank you!
> 
> But can it also be defined in a more handy   \MySpace[999]   ?
> Sorry, I tried some \def ... but didn't succeed.
> 
> Steffen
> 
> 
> 
> Am 24.10.2006 um 14:55 schrieb Taco Hoekwater:
> 
> >
> >
> > Steffen Wolfrum wrote:
> >> Hi,
> >>
> >> for fine-adjusting I need to have a variable horizontal space
> >> sometimes the width of "999" sometimes of "1", for example.
> >> Is there a command that reads the width of a character so it can be
> >> used in some kind of horizontal space?
> >
> > There is a \fontcharwd primitive to measure the width of a single
> > character is a specific font:
> >
> >    \hskip \the\fontcharwd \font `1
> >
> > but it may be easier to put the number(s) in a box and measure the
> > width of that:
> >
> >    \setbox\scratchbox=\hbox{999}%
> >    \hskip \the\wd \scratchbox
> >
> > Greetings, Taco

Hi Steffen,

your solution based on the method provided by Taco.

\def\MySpace
  {\dosingleempty\doMySpace}

\def\doMySpace[#1]%
  {\setbox\scratchbox=\hbox{#1}%
   \unskip\hskip \the\wd \scratchbox}

\starttext

Text\MySpace[999]Text

Text\MySpace[999] Text

Text \MySpace[999]Text

Text \MySpace[999] Text

\stoptext

Wolfgang


More information about the ntg-context mailing list