Download MetaFun - Pragma ADE

Transcript
240
\startuseMPgraphic{text draw}
draw
p withpen pencircle scaled 3pt withcolor red ;
drawarrow l withpen pencircle scaled 1pt withcolor green ;
drawarrow r withpen pencircle scaled 1pt withcolor blue ;
\stopuseMPgraphic
We use \includeMPgraphic to assemble the components:
\startuseMPgraphic{text}
\includeMPgraphic{text path}
\includeMPgraphic{text split}
\includeMPgraphic{text draw}
\stopuseMPgraphic
This graphic is typeset with \useMPgraphic{text}:
Before we are going to use them, we define some variables that specify the text. We use a baseline
distance of 8 points. The part of the line above the baseline is 7.2 points, while the (maximum)
depth is 2.8 points. These ratios are the ones we use in CONTEXT. Because we don't want the text
to touch the circle so we define an offset too also.
\startuseMPgraphic{text vars}
baselineskip := 8pt ;
strutheight := (7.2/10) * baselineskip ;
strutdepth
:= (2.8/10) * baselineskip ;
offset
:= baselineskip/2 ;
topskip
:= strutheight ;
\stopuseMPgraphic
We more of less achieve the offset by scaling the path. In doing so, we use the width and height,
which we call hsize and vsize, thereby conforming to the TEX naming scheme.
First we calculate both dimensions from the bounding box of the path. Next we down scale the
path to compensate for the offset. When done, we recalculate the dimensions.
\startuseMPgraphic{text move}
pair t, b ; path q, l, r ;
hsize := xpart lrcorner p - xpart llcorner p ;
Typesetting in METAPOST
Talking to TEX