summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/magazines/mag-0007-mkiv.tex
blob: 885d3cb14abff011c9fe0b7e4a129d011692f034 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
% language=uk

% author    : Hans Hagen
% copyright : PRAGMA ADE & ConTeXt Development Team
% license   : Creative Commons Attribution ShareAlike 4.0 International
% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions
% origin    : the ConTeXt distribution
%
% comment   : Because this manual is distributed with TeX distributions it comes with a rather
%             liberal license. We try to adapt these documents to upgrades in the (sub)systems
%             that they describe. Using parts of the content otherwise can therefore conflict
%             with existing functionality and we cannot be held responsible for that. Many of
%             the manuals contain characteristic graphics and personal notes or examples that
%             make no sense when used out-of-context.
%
% comment   : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt
%             Group journal or otherwise. Thanks to the editors for corrections. Also thanks
%             to users for testing, feedback and corrections.

\usemodule[mag-01,abr-02,visual]

\startbuffer[abstract]
    The \type {m-visual} module is used in some manuals that come with \CONTEXT\
    to generate random text. This is sometimes less confusing that nice quotes
    because the reader can then distinguish the explanation from the example.
    This module is not extensive (but may grow) and is just an addition to
    already built in visualization tools.
\stopbuffer

\startdocument
  [title={Faking Text and More},
   author=Hans Hagen,
   affiliation=PRAGMA ADE,
   date=August 2004,
   number=7 \MKIV]

\setupindenting[medium] \indenting[always] \setupwhitespace[none]

\subject{Remark}

When again a user asked me for the macros that I use to generate fake text, I
took a while to document them. Most macros use the built in random number
generator. In manuals you may want to control the randomization a bit. You can do
that by setting the seed:

\starttyping
\setupystem[random=12345]
\stoptyping

% Some more visualization tricks are discussed in the visual debugger modules \type
% {supp-vis.tex} and \type {core-vis.tex}. If you have special wishes, let me know.
% If they make sense (or more important: if they can be implemented in a decent
% way) they may be honored in the future.

In \MKIV\ there is a lot of visualization available like showing all boxes, glue,
characters etc.\ (try \type {\showmakeup}) . Many mechanism have dedicated
trackers that visualize matters with color. Here we just mention a few
possibilities of a module with helpers. This module is loaded with:

\starttyping
\usemodule[visual]
\stoptyping

\subject{Faking words}

We don't need much words to demonstrate the macros. Here we fake a single work
with \type {\fakeword}: \fakeword. You can fake a whole bunch with:

\startbuffer
\fakewords{100}{200} \par
\fakewords {30} {80} \par
\fakewords{200}{200}
\stopbuffer

\typebuffer \getbuffer

In addition to \type {\fakewords} we have \type {\fakenwords}. This time we don't
specify a range, but a number and a random seed.

\startbuffer
\fakenwords{100}{2} % words seed
\stopbuffer

\typebuffer \getbuffer

Drop caps can be faked as follows:

\startbuffer
\fakedroppedcaps{3}
\fakewords{100}{200} \par
\fakewords{100}{200}
\stopbuffer

\typebuffer \getbuffer

You can visualize the indentation by adding another faker:

\startbuffer
\fakeparindent \fakewords{100}{200}
\stopbuffer

\typebuffer \getbuffer

You can suppress indentation with:

\startbuffer
\onlyfakewords{100}{200}
\stopbuffer

\typebuffer \getbuffer

You can influence the color by redefining one or more of the folowing fake
colors:

\startbuffer
\definecolor[fakerulecolor]     [black]
\definecolor[fakebaselinecolor] [green]
\definecolor[fakeparindentcolor][blue]
\stopbuffer

\typebuffer \getbuffer

In case you wonder if fake words hyphenate, they kind of do, as is shown here:
\bgroup \showfakewords \onlyfakewords{100}{200} \egroup

\subject{Faking lines}

Lines can be faked with:

\startbuffer
\fakelines{3}{5}
\fakelines{4}{8}
\stopbuffer

\typebuffer \getbuffer

This is (of course) more efficient than faking words.

\subject{Faking figures}

Faking figures does not make that much sense.

\startbuffer
\fakefigure
  [left][]
  {10em}{12em}
  {3\lineheight}{5\lineheight}

\fakewords{100}{200}
\stopbuffer

\typebuffer \getbuffer

In this case the width will vary between \type {10em} and \type {12em}, while the
height end up somewhere between 3 and~5 times the lineheight.

If you want nice placeholders you can better use the \METAPOST\ \type {dum}
library. This one hooks into the external figure placement macros and will
produce a random graphic (with more or less random colors).

\startbuffer
\useMPlibrary[dum]
\placefigure
  [left][]
  {\fakewords{3}{6}}
  {\externalfigure[ForTheMomentFaked][width=3cm,height=2cm]}

\fakewords{100}{200}
\stopbuffer

\typebuffer \getbuffer

\subject{Faking formulas}

Another probably seldom used placeholder is \type {\fakeformula}:

\startbuffer
\startformula \fakeformula \stopformula
\stopbuffer

\typebuffer \getbuffer

An alternative, showing baselines, is:

\startbuffer
\startformula \fakespacingformula \stopformula
\stopbuffer

\typebuffer \getbuffer

You can trigger drawing of baseline yourself too:

\startbuffer
\showbaselines
\fakewords{100}{200} \par
\fakewords {30} {80} \par
\fakewords{200}{200}
\stopbuffer

\typebuffer \bgroup \getbuffer \egroup

In this case you will notice that this document is not typeset on a grid, and
therefore, since the blank space is set to big the baseline visualization shows
this distance when applicable.

\stopdocument