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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pbmtext User Manual</title></head>
<body>
<h1>pbmtext</h1>
Updated: 29 May 2020
<br>
<a href="#index">Table Of Contents</a>
<h2>NAME</h2>
pbmtext - render text into a PBM image
<h2 id="synopsis">SYNOPSIS</h2>
<b>pbmtext</b>
[<b>-wchar</b>]
[<b>-font</b> <i>fontfile</i>]
[<b>-builtin</b> <i>fontname</i>]
[<b>-space</b> <i>pixels</i>]
[<b>-lspace</b> <i>pixels</i>]
[<b>-nomargins</b>]
[<b>-width</b> <i>pixels</i>]
[<b>-load-entire-font</b>]
[<b>-verbose</b>]
[<b>-dry-run</b>]
[<b>-text-dump</b>]
[<i>text</i>]
<p>Minimum unique abbreviation of option is acceptable. You may use double
hyphens instead of single hyphen to denote options. You may use white
space in place of the equals sign to separate an option name from its value.
<h2 id="description">DESCRIPTION</h2>
<p>This program is part of <a href="index.html">Netpbm</a>.
<p><b>pbmtext</b> takes the specified text, either a single line from
the command line or multiple lines from standard input, and renders it
into a PBM graphical image.
<p>The text rendered is all the non-option command line arguments, separated
by spaces, except that if there are no non-option command line arguments, it
is Standard Input.
<p>In the image, each line of input is a line of output. Lines are
delimited by newline characters.
<p>The program renders any character in an input line that is not in the font
as a space. Note that control characters usually aren't in the font, but
some fonts have glyphs for them. The newline characters that delimit lines
in of Standard Input are not in any line.
<p>Tab characters are rendered as a number of spaces; any entry in the font
for the tab code point is irrelevant. The number of spaces is such as to
create tab stops every 8 characters. Note that this is not useful if the
font is proportional.
<p>The image is just wide enough for the longest line of text, plus
margins, and just high enough to contain the lines of text, plus
margins.
<p>The left and right margins are twice the width of the widest
character in the font; the top and bottom margins are the height of
the tallest character in the font. But if the text is only one line,
all the margins are half of this. You can use the <b>-nomargins</b> option
to eliminate the margins.
<p><b>pbmtext</b> renders left to right. It cannot render vertically
or right to left.
<p><b>pbmtextps</b> does the same thing as <b>pbmtext</b>, but uses
Ghostscript to generate the characters, which means you can use
Postscript fonts. But it also means you have to have Ghostscript
installed and it isn't as fast. Also, <b>pbmtextps</b> generates only
one line of text, whereas <b>pbmtext</b> can create multiple lines.
<p><b>pbmtext</b> is meant for simple text. If you're working with
a <em>document</em>, you would be better off using a document formatting
program to "print" to a Postscript file, then feeding that Postscript
to <b>pstopnm</b>.
<h2 id="options">OPTIONS</h2>
<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pbmtext</b> recognizes the following
command line options:
<dl compact>
<dt><b>-wchar</b>
<dd>
<p>By default, <b>pbmtext</b> takes a single-byte character stream as input.
When you specify <b>-wchar</b>, it treats input text as a multibyte character
stream encoded according to the current locale. Normally, the user would
supply a BDF font file encoded in ISO-10646-1 with a <b>-font</b> option.
<p>With <b>-wchar</b>, you cannot supply the text on the command line; it must
be fed from standard input.
<p>This option was new in Netpbm 10.82 (March 2018).
<dt><b>-font</b>
<dt><b>-builtin</b>
<dd>
<b>-builtin</b> selects a font among those built into Netpbm.
<b>-font</b> selects a font that you supply yourself either as an X Window
System BDF (Bitmap Distribution Format) file or as a PBM file in a special
form.
<p>The default is the built in font "bdf."
<p>"bdf" is Times-Roman 15 pixels high. (That's about 14
point type printed at 75 dpi).
<p>"fixed" is a built in fixed width font.
<p>For information about other fonts, and how to make one of your own,
see <a href="#fonts">Fonts</a> below.
<dt><b>-space</b> <i>pixels</i>
<dd> Add <i>pixels</i> pixels of space between characters. This is in
addition to whatever space surrounding characters is built into the
font, which is usually enough to produce a reasonable string of text.
<p><i>pixels</i> may be fractional, in which case the number of
pixels added varies so as to achieve the specified average. For
example <b>-space=1.5</b> causes half the spaces to be 1 pixel and
half to be 2 pixels.
<p><i>pixels</i> may be negative to crowd text together, but the
author has not put much thought or testing into how this works in
every possible case, so it might cause disastrous results.
<dt><b>-lspace</b> <i>pixels</i>
<dd> Add <i>pixels</i> pixels of space between lines. This is in
addition to whatever space above and below characters is built into
the font, which is usually enough to produce a reasonable line
spacing.
<p><i>pixels</i> must be a whole number.
<p><i>pixels</i> may be negative to crowd lines together, but the
author has not put much thought or testing into how this works in
every possible case, so it might cause disastrous results.
<dt><b>-nomargins</b>
<dd>By default, <b>pbmtext</b> adds margins all around the image as
described above. This option causes <b>pbmtext</b> not to add any
margins.
<p>Note that there may still be space beyond the edges of the type
because a character itself may include space at its edges. To eliminate
all surrounding background, so the type touches all four edges of the
image, use <b>pnmcrop</b>.
<dt><b>-width</b> <i>pixels</i>
<dd>This specifies how much horizontal space the text is supposed to fit
into.
<p>If the input is one line, <b>pbmtext</b> breaks it into multiple
lines as needed to fit the specified width. It breaks it between
characters, but does not pay attention to white space; it may break in
the middle of a word and a line may begin or end with white space.
<p>If the input is multiple lines, <b>pbmtext</b> assumes you already
have line breaks where they make sense, and <b>pbmtext</b> simply
truncates each line as needed to fit the specified width.
<dt><b>-load-entire-font</b>
<dd>When you use a BDF font, <b>pbmtext</b> will normally load from the font
only the characters needed for your text, not wasting time loading other
characters. With this option, <b>pbmtext</b> will instead read the entire
font. It won't make any difference in the rendered output, but it lets
you check the integrity of the font file.
<p>This option was new in Netpbm 10.91 (June 2020). Before that,
<b>pbmtext</b> always reads the entire font.
<dt><b>-verbose</b>
<dd>
This makes <b>pbmtext</b> issue informtional messages about its processing.
<dt><b>-dry-run</b>
<dd>
<p>With this option, instead of outputting an image of the text,
<b>pbmtext</b> just writes to Standard Output a message telling the dimensions
of the image it would have produced.
<p>You can specify only one of <b>-dry-run</b> and <b>-text-dump</b>.
<p>This option was new in Netpbm 10.75 (June 2016).
<dt><b>-text-dump</b>
<dd>
This option causes <b>pbmtext</b> just to write to Standard Output the text in
ASCII that would be rendered. The output reflects any text formatting,
unprintable character substitution, tab expansion, etc. It is for diagnosing
problems. This option was new in Netpbm 10.82 (March 2018).
<p>When <b>-wchar</b> is in effect, the output text will be in the encoding
specified by the current locale.
<p>You can specify only one of <b>-dry-run</b> and <b>-text-dump</b>.
<p>This option was new in Netpbm 10.82 (March 2018).
</dl>
<h2 id="usage">USAGE</h2>
<p>Often, you want to place text over another image. One way to do this is
with <b>ppmlabel</b>. For more flexible (but complex) drawing of text on an
image, there is <b>ppmdraw</b>. These do not give you the font options that
<b>pbmtext</b> does, though.
<p>Another way is to use <b>pbmtext</b> to create an image containing
the text, then use <b>pamcomp</b> to overlay the text image onto your
base image. To make only the text (and not the entire rectangle
containing it) cover the base image, you will need to give
<b>pamcomp</b> a mask, via its <b>-alpha</b> option. You can just use
the text image itself as the mask, as long as you also specify the
<b>-invert</b> option to <b>pamcomp</b>.
<p>If you want to overlay colored text instead of black, just use
<b>ppmchange</b> to change all black pixels to the color of your
choice before overlaying the text image. But still use the original
black and white image for the transparency mask.
<p>If you want the text at an angle, use <b>pnmrotate</b> on the text
image (and transparency mask) before overlaying.
<h2 id="fonts">FONTS</h2>
<p>There are three kinds of fonts you an use with <b>pbmtext</b>:
<ul>
<li>built in
<li>BDF
<li>PBM
</ul>
<h3>Built In Fonts</h3>
<p>There are two built in fonts: <b>bdf</b> and <b>fixed</b>. You select
these fonts with a <b>-builtin</b> option.
<p><b>bdf</b> is the default when you specify no font information on the
command line. <i>The naming reflects the fact that it shares many
characteristics of BDF style fonts. When this font was implemented,
<b>pbmtext</b> did not have the ability to read arbitrary BDF fonts
specified by the <b>-font</b> option. There is no external font file
involved.</i>
<p><b>bdf</b> is encoded in ISO 8859-1 (Latin 1, 8-bit). In addition to
English it can handle most West European languages (Spanish, French, German,
Swedish ...) This set lacks the Euro currency sign.
<p><b>fixed</b> is ASCII (7-bit) only.
<p>While it is not an error to do so, you should not use the above built-in
fonts with <b>-wchar</b>.
<h3>BDF Font</h3>
<p>BDF is an ancient font format that at one time was standard for the X
Window System. Now, you don't see it very often. Until about 2024, you could
find some BDF fonts on the Xfree86 web site. Today, you can get the full
package of the BDF fonts from XFree86 from
the <a href="http://netpbm.sourceforge.net/bdffont.tgz">Netpbm web site</a>.
<h3>PBM Font</h3>
<p>To create a font as a PBM file (to use with the <b>-font</b>
option), you just create a PBM image of the text matrix below.
<p>The first step is to display text matrix below on the screen,
e.g. in an X11 window.
<pre>
M ",/^_[`jpqy| M
/ !"#$%&'()*+ /
< ,-./01234567 <
> 89:;<=>?@ABC >
@ DEFGHIJKLMNO @
_ PQRSTUVWXYZ[ _
{ \]^_`abcdefg {
} hijklmnopqrs }
~ tuvwxyz{|}~ ~
M ",/^_[`jpqy| M
</pre>
<p>Make sure it's a fixed width font -- This should display as a
perfect rectangle.
<p>Also, try to use a simple display program. Pbmtext divides this
into a matrix of cells, all the same size, each containing one
character, so it is important that whatever you use to display it
display with uniform horizontal and vertical spacing. Fancy word
processing programs sometimes stretch characters in both directions to
fit certain dimensions, and that won't work. Sometimes a display
program scales a font to show a character larger or smaller than its
natural size. That too won't often work because the rounding involved
in such scaling causes non-uniform distances between characters.
<p>If you display the text matrix improperly, the usual symptom is
that when you try to use the font, <b>pbmtext</b> fails with an error
message telling you that the number of lines in the font isn't
divisible by 11, or it can't find the blank band around the inner
rectangle. Sometimes the symptom is that one of the characters
displays with a piece of the character that is next to it in the
matrix. For example, "l" might display with a little piece
of the "m" attached on its right.
<p>Do a screen grab or window dump of that text, using for instance
<b>xwd</b>, <b>xgrabsc</b>, or <b>screendump</b>. Convert the result into a
pbm file. If necessary, use <b>pamcut</b> to remove anything you grabbed in
addition to the text pictured above (or be a wimp and use a graphical editor
such as Gimp). Finally, run it through <b>pnmcrop</b> to make sure the edges
are right up against the text. <b>pbmtext</b> can figure out the sizes and
spacings from that.
<p>There are some historical computer fonts, such as that used by the original
IBM PC, in the form that you can screen-grab and turn into a PBM font file
available from <a href="http://scruss.com/enterprise.net/pbmtext.html">Stewart
C Russell</a>. There are fonts with various duodecimal digit glyphs at
<a href="http://treisaran.deviantart.com/gallery/38695571/NetPBM-Fonts">
treisara.deviantart.com</a>.
<p>PBM fonts cannot be used with <b>-wchar</b>.
<h2 id="multibyte">MULTI-BYTE INPUT</h2>
<p>In the past, English text was encoded in 7-bit ASCII. 8-bit and multibyte
encodings were needed only for non-English languages. This is not the case
today. As of this writing, 90% of all web pages are encoded in UTF-8. While
many of them are actually restricted to 7-bit ASCII, which is a subset of
UTF-8, English text encoded in UTF-8 commonly employs "66 99" style quotation
marks, which do not appear in ASCII.
<p>If your input text is UTF-8, you should use <b>-wchar</b>. You may have to
tweak the locale setting. <b>pbmtext</b> recognizes code points up to 65535.
This is sufficient for the vast majority of text written in modern languages.
<p>In the default single-byte (or "narrow") character
mode, <b>pbmtext</b> can handle 7-bit and 8-bit character sets.
Examples are ASCII, ISO 8859 family, koi8-r/u and VISCII. It is up to
the user to supply a BDF file covering the necessary glyphs with the
"-font" option. The font file must be in the right encoding.
<p><b>pbmtext</b> does not inspect the encoding of the font file.
<h2 id="limitations">LIMITATIONS</h2>
<p>If the text is from Standard Input, no line may be longer than 4999
characters. If one is, the program aborts with an appropriate error message.
<p>If the text is from Standard Input and contains a null character, the
results are abnormal. Lines may be truncated, and a single line may be
considered multiple lines. Normal text does not contain null characters, so
this isn't a big problem.
<h2 id="tips">TIPS</h2>
<p>If you get garbled output, check the input text encoding and font file
encoding. When using <b>-wchar</b>, also check the current locale.
<p>To convert the encoding of a text file, use <b>iconv</b> or <b>luit</b>.
<p>To check the encoding of a BDF file, examine the CHARSET_REGISTRY
line and the next line, which should be CHARSET_ENCODING:
<pre>
<kbd>
$ grep -A1 CHARSET_REGISTRY font-a.bdf
CHARSET_REGISTRY "ISO8859"
CHARSET_ENCODING "1"
$ grep -A1 CHARSET_REGISTRY font-b.bdf
CHARSET_REGISTRY "ISO10646"
CHARSET_ENCODING "1"
</kbd>
</pre>
<p>The latter is Unicode. BDF files coded in ISO 16046-1 usually work for
Western European languages, because ISO 16046-1 expands ISO 8859-1 (also
called "Latin-1") while maintaining the first 256 code points. ISO
8859-1 itself is a superset of ASCII. Run the above command and verify the
necessary glyphs are present.
<p><strong>IMPORTANT:</strong> For input text, a different rule applies. If
you feed ISO 8859-1 text to <b>pbmtext -wchar</b> set up for UTF-8, the output
will be garbled. Unicode provides several encoding schemes and different ones
are in effect for input text and font. <em>The difference between Unicode
codepoint and the various encodings is a formidable stumbling block; beware of
web pages that get the concept wrong.</em>
<p>75% of the BDF files in the font collection available from
<a href="http://netpbm.sourceforge.net/bdffont.tgz">the Netpbm website</a> are
in ISO 10646-1. Many have the Euro sign, Greek letters, etc., but they are
placed at code points available to <b>pbmtext</b> only with <b>-wchar</b>.
<p>Before <b>pbmtext</b> had the <b>-wchar</b> option, one often had to
produce a BDF file in an 8-bit encoding from a master BDF file encoded in ISO
10646-1.
<p>There are several programs that perform BDF encoding conversion. If you
have the X Window System installed, first look for <b>ucs2any</b>. If you
don't, you can download <b>ucs2any.pl</b> from <a
href="http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html">Unicode fonts and tools
for X11</a>. This website has much useful information on fonts.
<p>Another converter is <b>trbdf</b>, included in the "trscripts"
package, available in some GNU/Linux distributions.
<p>BDF files encoded in ISO 8859-2, ISO 8859-7, koi8-r, etc. are available
from <a href="http://czyborra.com/charsets/iso8859.html">ISO 8859 Alphabet
Soup</a> and its sister page <a
href="http://czyborra.com/charsets/cyrillic.html">The Cyrillic Charset
Soup</a>. Though the information is dated, these pages give a good overview
of 8-bit character sets.
<p>To convert OTF or TTF font files to BDF, use
<b>otf2bdf</b> by Mike Leisher or <b>otftobdf</b> (part of the <b>libotf</b>
package, which is part of the <a href="https://www.nongnu.org/m17n/">
<b>m17n</b></a> project).
<h2 id="seealso">SEE ALSO</h2>
<b><a href="pbmtextps.html">pbmtextps</a></b>,
<b><a href="pamcut.html">pamcut</a></b>,
<b><a href="pnmcrop.html">pnmcrop</a></b>,
<b><a href="pamcomp.html">pamcomp</a></b>,
<b><a href="ppmchange.html">ppmchange</a></b>,
<b><a href="pnmrotate.html">pnmrotate</a></b>,
<b><a href="ppmlabel.html">ppmlabel</a></b>,
<b><a href="ppmdraw.html">ppmdraw</a></b>,
<b><a href="pstopnm.html">pstopnm</a></b>,
<b><a href="pbm.html">pbm</a></b>,
<b><a href="http://www.pango.org">Pango</a></b>,
<b><a href="http://cairographics.org">Cairo</a></b>
<h2 id="author">AUTHOR</h2>
Copyright (C) 1993 by Jef Poskanzer and George Phillips
<hr>
<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<li><a href="#options">OPTIONS</a>
<li><a href="#usage">USAGE</a>
<li><a href="#fonts">FONTS</a>
<li><a href="#multibyte">MULTI-BYTE INPUT</a>
<li><a href="#limitations">LIMITATIONS</a>
<li><a href="#tips">TIPS</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#author">AUTHOR</a>
</ul>
</body>
</html>
|