ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: followtokens
Date: Fri, 13 Jan 2006 19:09:44 +0100	[thread overview]
Message-ID: <43C7ECE8.1010802@wxs.nl> (raw)
In-Reply-To: <b78ca0f80601130939w2001386ck@mail.gmail.com>

Alexandre Billon wrote:

> Dear all,
>
> I am quite new to context (but love it) and i am trying tind a way to 
> typeset texts "properly kerned" in such a way that the characters be 
> all rotated with tiny randomized angle (strange project indeed). I 
> tried to do it by writing a macro inspired by \followtokens. I have 
> two questions :
>
> 1. It works but just for text within a single line :  I have no clue 
> how  to manage the line breaking, and I have to admit that I don't 
> know eanough TeX ConTeXt to find out.
>
> 2. In playing with the macro followtoken I happened to write two files 
> with no apparent significant difference (I mean for me) but which give 
> quite different results : one properly kerned, and another that is 
> not. Could someone explain me what's happening here ? (files attached)
>
\startMPenvironment[global]
    \definefont[RotFont][RegularBold]
\stopMPenvironment

\def\whatever#1%
  {\appendtoks#1\to\MPtoks
   \setbox\MPbox=\hbox{\RotFont\setstrut\strut\the\MPtoks}%
   \startMPdrawing
        n := n + 1 ; len[n] := \the\wd\MPbox ;
   \stopMPdrawing
   \startMPdrawing[-]
        pic[n] := btex \RotFont\setstrut\strut#1 etex ;
   \stopMPdrawing}

\def\funnywriting#1%
  {\bgroup
   \resetMPdrawing
   \startMPdrawing
        picture pic[] ;
        numeric wid[], len[], pos[], n ;
        wid[0] := len[0] := pos[0] := n := 0 ;
   \stopMPdrawing
   \handletokens#1\with\whatever
   \startMPdrawing
        for i=1 upto n :
            wid[i] := abs(xpart lrcorner pic[i] - xpart llcorner pic[i]) ;
            pos[i] := len[i]-wid[i] ;
            pic[i] := pic[i] rotatedaround(origin, -10 randomized 20) ;
            pic[i] := pic[i] shifted (pos[i],0) ;
            draw pic[i];
        endfor ;
   \stopMPdrawing
   \MPdrawingdonetrue
   \getMPdrawing
   \resetMPdrawing
   \egroup}

\starttext
    \funnywriting{La vie est belle}
\stoptext

watch the rotatedaround: you have to provide a pair as first argument 
(so both your files failed)

Hans

      reply	other threads:[~2006-01-13 18:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-13 17:39 followtokens Alexandre Billon
2006-01-13 18:09 ` Hans Hagen [this message]

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=43C7ECE8.1010802@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).