luametafun-text.tex /size: 3180 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/luametafun
2
3\environment luametafun-style
4
5\startcomponent luametafun-text
6
7\startchapter[title={Text}]
8
9The \METAFUN\ \type {textext} command normally can do the job of typesetting a
10text snippet quite well.
11
12\startbuffer
13\startMPcode
14    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
15    draw textext("\bf This is text A") withcolor "white" ;
16\stopMPcode
17\stopbuffer
18
19\typebuffer[option=TEX]
20
21We get:
22
23\startlinecorrection
24\getbuffer
25\stoplinecorrection
26
27You can use regular \CONTEXT\ commands, so this is valid:
28
29\startbuffer
30\startMPcode
31    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
32    draw textext("\framed{\bf This is text A}") withcolor "white" ;
33\stopMPcode
34\stopbuffer
35
36\typebuffer[option=TEX]
37
38Of course you can as well draw a frame in \METAPOST\ but the \type {\framed}
39command has more options, like alignments.
40
41\startlinecorrection
42\getbuffer
43\stoplinecorrection
44
45Here is a variant using the \METAFUN\ interface:
46
47\startbuffer
48\startMPcode
49    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
50    draw lmt_text [
51        text  = "This is text A",
52        color = "white",
53        style = "bold"
54    ] ;
55\stopMPcode
56\stopbuffer
57
58\typebuffer[option=TEX]
59
60The outcome is more or less the same:
61
62\startlinecorrection
63\getbuffer
64\stoplinecorrection
65
66Here is another example. The \type {format} option is actually why this command
67is provided.
68
69\startbuffer
70\startMPcode
71    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
72    draw lmt_text [
73        text   = decimal 123.45678,
74        color  = "white",
75        style  = "bold",
76        format = "@0.3F",
77    ] ;
78\stopMPcode
79\stopbuffer
80
81\typebuffer[option=TEX]
82
83\startlinecorrection
84\getbuffer
85\stoplinecorrection
86
87The following parameters can be set:
88
89\starttabulate[|T|T|T|p|]
90\FL
91\BC name     \BC type    \BC default \BC comment \NC \NR
92\ML
93\NC offset   \NC numeric \NC 0       \NC \NC \NR
94\NC strut    \NC string  \NC auto    \NC adapts the dimensions to the font (\type {yes} uses the the default strut) \NC \NR
95\NC style    \NC string  \NC         \NC \NC \NR
96\NC color    \NC string  \NC         \NC \NC \NR
97\NC text     \NC string  \NC         \NC \NC \NR
98\NC anchor   \NC string  \NC         \NC one of these \type {lft}, \type {urt} like anchors \NC \NR
99\NC format   \NC string  \NC         \NC a format specifier using \type {@} instead of a percent sign \NC \NR
100\NC position \NC pair    \NC origin  \NC \NC \NR
101\NC trace    \NC boolean \NC false   \NC \NC \NR
102\LL
103\stoptabulate
104
105The next example demonstrates the positioning options:
106
107\startbuffer
108\startMPcode
109    fill fullcircle xyscaled (8cm,1cm) withcolor "darkblue" ;
110    fill fullcircle scaled .5mm withcolor "white" ;
111    draw lmt_text [
112        text     = "left",
113        color    = "white",
114        style    = "bold",
115        anchor   = "lft",
116        position = (-1mm,2mm),
117    ] ;
118    draw lmt_text [
119        text   = "right",
120        color  = "white",
121        style  = "bold",
122        anchor = "rt",
123        offset = 3mm,
124    ] ;
125\stopMPcode
126\stopbuffer
127
128\typebuffer[option=TEX]
129
130\startlinecorrection
131\getbuffer
132\stoplinecorrection
133
134
135\stopchapter
136
137\stopcomponent
138