summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/luametafun/luametafun-text.tex
blob: 4f08ee00f8c73ea2806d7ff14d7a6ea4d2db61c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
% language=us

\environment luametafun-style

\startcomponent luametafun-text

\startchapter[title={Text}]

The \METAFUN\ \type {textext} command normally can do the job of typesetting a
text snippet quite well.

\startbuffer
\startMPcode
    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
    draw textext("\bf This is text A") withcolor "white" ;
\stopMPcode
\stopbuffer

\typebuffer[option=TEX]

We get:

\startlinecorrection
\getbuffer
\stoplinecorrection

You can use regular \CONTEXT\ commands, so this is valid:

\startbuffer
\startMPcode
    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
    draw textext("\framed{\bf This is text A}") withcolor "white" ;
\stopMPcode
\stopbuffer

\typebuffer[option=TEX]

Of course you can as well draw a frame in \METAPOST\ but the \type {\framed}
command has more options, like alignments.

\startlinecorrection
\getbuffer
\stoplinecorrection

Here is a variant using the \METAFUN\ interface:

\startbuffer
\startMPcode
    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
    draw lmt_text [
        text  = "This is text A",
        color = "white",
        style = "bold"
    ] ;
\stopMPcode
\stopbuffer

\typebuffer[option=TEX]

The outcome is more or less the same:

\startlinecorrection
\getbuffer
\stoplinecorrection

Here is another example. The \type {format} option is actually why this command
is provided.

\startbuffer
\startMPcode
    fill fullcircle xyscaled (8cm,1cm) withcolor "darkred" ;
    draw lmt_text [
        text   = decimal 123.45678,
        color  = "white",
        style  = "bold",
        format = "@0.3F",
    ] ;
\stopMPcode
\stopbuffer

\typebuffer[option=TEX]

\startlinecorrection
\getbuffer
\stoplinecorrection

The following parameters can be set:

\starttabulate[|T|T|T|p|]
\FL
\BC name     \BC type    \BC default \BC comment \NC \NR
\ML
\NC offset   \NC numeric \NC 0       \NC \NC \NR
\NC strut    \NC string  \NC auto    \NC adapts the dimensions to the font (\type {yes} uses the the default strut) \NC \NR
\NC style    \NC string  \NC         \NC \NC \NR
\NC color    \NC string  \NC         \NC \NC \NR
\NC text     \NC string  \NC         \NC \NC \NR
\NC anchor   \NC string  \NC         \NC one of these \type {lft}, \type {urt} like anchors \NC \NR
\NC format   \NC string  \NC         \NC a format specifier using \type {@} instead of a percent sign \NC \NR
\NC position \NC pair    \NC origin  \NC \NC \NR
\NC trace    \NC boolean \NC false   \NC \NC \NR
\LL
\stoptabulate

The next example demonstrates the positioning options:

\startbuffer
\startMPcode
    fill fullcircle xyscaled (8cm,1cm) withcolor "darkblue" ;
    fill fullcircle scaled .5mm withcolor "white" ;
    draw lmt_text [
        text     = "left",
        color    = "white",
        style    = "bold",
        anchor   = "lft",
        position = (-1mm,2mm),
    ] ;
    draw lmt_text [
        text   = "right",
        color  = "white",
        style  = "bold",
        anchor = "rt",
        offset = 3mm,
    ] ;
\stopMPcode
\stopbuffer

\typebuffer[option=TEX]

\startlinecorrection
\getbuffer
\stoplinecorrection


\stopchapter

\stopcomponent