1Pbmtext User Manual(0) Pbmtext User Manual(0)
2
3
4
6 pbmtext - render text into a PBM image
7
8
10 pbmtext [-wchar] [-font fontfile] [-builtin fontname] [-space pixels]
11 [-lspace pixels] [-nomargins] [-width pixels] [-dry-run] [-text-dump]
12 [text]
13
14 Minimum unique abbreviation of option is acceptable. You may use dou‐
15 ble hyphens instead of single hyphen to denote options. You may use
16 white space in place of the equals sign to separate an option name from
17 its value.
18
19
20
22 This program is part of Netpbm(1).
23
24 pbmtext takes the specified text, either a single line from the command
25 line or multiple lines from standard input, and renders it into a PBM
26 graphical image.
27
28 The text rendered is all the non-option command line arguments, sepa‐
29 rated by spaces, except that if there are no non-option command line
30 arguments, it is Standard Input.
31
32
33 In the image, each line of input is a line of output. Formatting char‐
34 acters such as newline have no effect on the formatting; like any
35 unprintable character, they turn into spaces.
36
37 The image is just wide enough for the longest line of text, plus mar‐
38 gins, and just high enough to contain the lines of text, plus margins.
39
40 The left and right margins are twice the width of the widest character
41 in the font; the top and bottom margins are the height of the tallest
42 character in the font. But if the text is only one line, all the mar‐
43 gins are half of this. You can use the -nomargins option to eliminate
44 the margins.
45
46 pbmtext renders left to right. It cannot render vertically or right to
47 left.
48
49 pbmtextps does the same thing as pbmtext, but uses Ghostscript to gen‐
50 erate the characters, which means you can use Postscript fonts. But it
51 also means you have to have Ghostscript installed and it isn't as fast.
52 Also, pbmtextps generates only one line of text, whereas pbmtext can
53 create multiple lines.
54
55 pbmtext is meant for simple text. If you're working with a document,
56 you would be better off using a document formatting program to "print"
57 to a Postscript file, then feeding that Postscript to pstopnm.
58
59
61 -wchar
62
63 By default, pbmtext takes a single-byte character stream as
64 input. When you specify -wchar, it treats input text as a
65 multibyte character stream encoded according to the current
66 locale. Normally, the user would supply a BDF font file encoded
67 in ISO-10646-1 with a -font option.
68
69 With -wchar, you cannot supply the text on the command line; it
70 must be fed from standard input.
71
72 This option was new in Netpbm 10.82 (March 2018).
73
74
75
76 -font
77
78 -builtin
79 -builtin selects a font among those built into Netpbm.
80
81 -font selects a font that you supply yourself either as an X
82 Window System BDF (Bitmap Distribution Format)
83 ⟨http://xfree86.org/current/bdf.pdf⟩ file or as a PBM file in a
84 special form.
85
86 The default is the built in font "bdf."
87
88 "bdf" is Times-Roman 15 pixels high. (That's about 14 point
89 type printed at 75 dpi).
90
91 "fixed" is a built in fixed width font.
92
93 For information about other fonts, and how to make one of your
94 own, see Fonts ⟨#fonts⟩ below.
95
96
97
98 -space pixels
99 Add pixels pixels of space between characters. This is in
100 addition to whatever space surrounding characters is built into
101 the font, which is usually enough to produce a reasonable string
102 of text.
103
104 pixels may be fractional, in which case the number of pixels
105 added varies so as to achieve the specified average. For exam‐
106 ple -space=1.5 causes half the spaces to be 1 pixel and half to
107 be 2 pixels.
108
109 pixels may be negative to crowd text together, but the author
110 has not put much thought or testing into how this works in every
111 possible case, so it might cause disastrous results.
112
113
114 -lspace pixels
115 Add pixels pixels of space between lines. This is in addition
116 to whatever space above and below characters is built into the
117 font, which is usually enough to produce a reasonable line spac‐
118 ing.
119
120 pixels must be a whole number.
121
122 pixels may be negative to crowd lines together, but the author
123 has not put much thought or testing into how this works in every
124 possible case, so it might cause disastrous results.
125
126
127 -nomargins
128 By default, pbmtext adds margins all around the image as
129 described above. This option causes pbmtext not to add any mar‐
130 gins.
131
132 Note that there may still be space beyond the edges of the type
133 because a character itself may include space at its edges. To
134 eliminate all surrounding background, so the type touches all
135 four edges of the image, use pnmcrop.
136
137
138 -width pixels
139 This specifies how much horizontal space the text is supposed to
140 fit into.
141
142 If the input is one line, pbmtext breaks it into multiple lines
143 as needed to fit the specified width. It breaks it between
144 characters, but does not pay attention to white space; it may
145 break in the middle of a word and a line may begin or end with
146 white space.
147
148 If the input is multiple lines, pbmtext assumes you already have
149 line breaks where they make sense, and pbmtext simply truncates
150 each line as needed to fit the specified width.
151
152
153 -dry-run
154
155 With this option, instead of outputting an image of the text,
156 pbmtext just writes to Standard Output a message telling the
157 dimensions of the image it would have produced.
158
159 You can specify only one of -dry-run and -text-dump.
160
161 This option was new in Netpbm 10.75 (June 2016).
162
163
164 -text-dump
165 This option causes pbmtext just to write to Standard Output the
166 text in ASCII that would be rendered. The output reflects any
167 text formatting, unprintable character substitution, tab expan‐
168 sion, etc. It is for diagnosing problems. This option was new
169 in Netpbm 10.82 (March 2018).
170
171 When -wchar is in effect, the output text will be in the encod‐
172 ing specified by the current locale.
173
174 You can specify only one of -dry-run and -text-dump.
175
176 This option was new in Netpbm 10.82 (March 2018).
177
178
179
180
181
183 Often, you want to place text over another image. One way to do this
184 is with ppmlabel. For more flexible (but complex) drawing of text on
185 an image, there is ppmdraw. These do not give you the font options
186 that pbmtext does, though.
187
188 Another way is to use pbmtext to create an image containing the text,
189 then use pamcomp to overlay the text image onto your base image. To
190 make only the text (and not the entire rectangle containing it) cover
191 the base image, you will need to give pamcomp a mask, via its -alpha
192 option. You can just use the text image itself as the mask, as long as
193 you also specify the -invert option to pamcomp.
194
195 If you want to overlay colored text instead of black, just use ppm‐
196 change to change all black pixels to the color of your choice before
197 overlaying the text image. But still use the original black and white
198 image for the transparency mask.
199
200 If you want the text at an angle, use pnmrotate on the text image (and
201 transparency mask) before overlaying.
202
203
205 There are three kinds of fonts you an use with pbmtext:
206
207
208
209 · built in
210
211 · BDF
212
213 · PBM
214
215
216
217 Built In Fonts
218 There are two built in fonts: bdf and fixed. You select these fonts
219 with a -builtin option.
220
221 bdf is the default when you specify no font information on the command
222 line. The naming reflects the fact that it shares many characteristics
223 of BDF style fonts. When this font was implemented, pbmtext did not
224 have the ability to read arbitrary BDF fonts specified by the -font
225 option. There is no external font file involved.
226
227 bdf is encoded in ISO 8859-1 (Latin 1, 8-bit). In addition to English
228 it can handle most West European languages (Spanish, French, German,
229 Swedish ...) This set lacks the Euro currency sign.
230
231 fixed is ASCII (7-bit) only.
232
233 While it is not an error to do so, you should not use the above built-
234 in fonts with -wchar.
235
236
237
238 BDF Font
239 BDF is an ancient font format that at one time was standard for the X
240 Window System. Now, you don't see it very often, but you can find some
241 BDF fonts on the Xfree86
242 ⟨http://cvsweb.xfree86.org/cvsweb/xc/fonts/bdf/⟩ web site.
243
244 You can get the full package of the BDF fonts from XFree86 (see above)
245 from the Netpbm web site ⟨http://netpbm.sourceforge.net/bdffont.tgz⟩ .
246
247
248 PBM Font
249 To create a font as a PBM file (to use with the -font option), you just
250 create a PBM image of the text matrix below.
251
252 The first step is to display text matrix below on the screen, e.g. in
253 an X11 window.
254
255
256 M ",/^_[`jpqy| M
257
258 / !"#$%&'()*+ /
259 < ,-./01234567 <
260 > 89:;<=>?@ABC >
261 @ DEFGHIJKLMNO @
262 _ PQRSTUVWXYZ[ _
263 { \]^_`abcdefg {
264 } hijklmnopqrs }
265 ~ tuvwxyz{|}~ ~
266
267 M ",/^_[`jpqy| M
268
269
270 Make sure it's a fixed width font -- This should display as a perfect
271 rectangle.
272
273 Also, try to use a simple display program. Pbmtext divides this into a
274 matrix of cells, all the same size, each containing one character, so
275 it is important that whatever you use to display it display with uni‐
276 form horizontal and vertical spacing. Fancy word processing programs
277 sometimes stretch characters in both directions to fit certain dimen‐
278 sions, and that won't work. Sometimes a display program scales a font
279 to show a character larger or smaller than its natural size. That too
280 won't often work because the rounding involved in such scaling causes
281 non-uniform distances between characters.
282
283 If you display the text matrix improperly, the usual symptom is that
284 when you try to use the font, pbmtext fails with an error message
285 telling you that the number of lines in the font isn't divisible by 11,
286 or it can't find the blank band around the inner rectangle. Sometimes
287 the symptom is that one of the characters displays with a piece of the
288 character that is next to it in the matrix. For example, "l" might
289 display with a little piece of the "m" attached on its right.
290
291 Do a screen grab or window dump of that text, using for instance xwd,
292 xgrabsc, or screendump. Convert the result into a pbm file. If neces‐
293 sary, use pamcut to remove anything you grabbed in addition to the text
294 pictured above (or be a wimp and use a graphical editor such as Gimp).
295 Finally, run it through pnmcrop to make sure the edges are right up
296 against the text. pbmtext can figure out the sizes and spacings from
297 that.
298
299 There are some historical computer fonts, such as that used by the
300 original IBM PC, in the form that you can screen-grab and turn into a
301 PBM font file available from Stewart C Russell" (1). There are fonts
302 with various duodecimal digit glyphs at
303 treisara.deviantart.com
304 ⟨http://treisaran.deviantart.com/gallery/38695571/NetPBM-Fonts⟩ .
305
306 PBM fonts cannot be used with -wchar.
307
308
309
310
312 In the past, English text was encoded in 7-bit ASCII. 8-bit and multi‐
313 byte encodings were needed only for non-English languages. This is not
314 the case today. As of this writing, 90% of all web pages are encoded
315 in UTF-8. While many of them are actually restricted to 7-bit ASCII,
316 which is a subset of UTF-8, English text encoded in UTF-8 commonly
317 employs "66 99" style quotation marks, which do not appear in ASCII.
318
319 If your input text is UTF-8, you should use -wchar. You may have to
320 tweak the locale setting. pbmtext recognizes code points up to 65535.
321 This is sufficient for the vast majority of text written in modern lan‐
322 guages.
323
324 In the default single-byte (or "narrow") character mode, pbmtext can
325 handle 7-bit and 8-bit character sets. Examples are ASCII, ISO 8859
326 family, koi8-r/u and VISCII. It is up to the user to supply a BDF file
327 covering the necessary glyphs with the "-font" option. The font file
328 must be in the right encoding.
329
330 pbmtext does not inspect the encoding of the font file.
331
332
333
335 If the text is from Standard Input, no line may be longer than 4999
336 characters. If one is, the program aborts with an appropriate error
337 message.
338
339 If the text is from Standard Input and contains a null character, the
340 results are abnormal. Lines may be truncated, and a single line may be
341 considered multiple lines. Normal text does not contain null charac‐
342 ters, so this isn't a big problem.
343
344
345
347 If you get garbled output, check the input text encoding and font file
348 encoding. When using -wchar, also check the current locale.
349
350 To convert the encoding of a text file, use iconv or luit.
351
352 To check the encoding of a BDF file, examine the CHARSET_REGISTRY line
353 and the next line, which should be CHARSET_ENCODING:
354
355 $ grep -A1 CHARSET_REGISTRY font-a.bdf
356 CHARSET_REGISTRY "ISO8859"
357 CHARSET_ENCODING "1"
358
359 $ grep -A1 CHARSET_REGISTRY font-b.bdf
360 CHARSET_REGISTRY "ISO10646"
361 CHARSET_ENCODING "1"
362
363 The latter is Unicode. BDF files coded in ISO 16046-1 usually work for
364 Western European languages, because ISO 16046-1 expands ISO 8859-1
365 (also called "Latin-1") while maintaining the first 256 code points.
366 ISO 8859-1 itself is a superset of ASCII. Run the above command and
367 verify the necessary glyphs are present.
368
369 IMPORTANT: For input text, a different rule applies. If you feed ISO
370 8859-1 text to pbmtext -wchar set up for UTF-8, the output will be gar‐
371 bled. Unicode provides several encoding schemes and different ones are
372 in effect for input text and font. The difference between Unicode
373 codepoint and the various encodings is a formidable stumbling block;
374 beware of web pages that get the concept wrong.
375
376 75% of the BDF files in the font collection available from the Netpbm
377 website ⟨http://netpbm.sourceforge.net/bdffont.tgz⟩ are in ISO
378 10646-1. Many have the Euro sign, Greek letters, etc., but they are
379 placed at code points available to pbmtext only with -wchar.
380
381 Before pbmtext had the -wchar option, one often had to produce a BDF
382 file in an 8-bit encoding from a master BDF file encoded in ISO
383 10646-1.
384
385 There are several programs that perform BDF encoding conversion. If
386 you have the X Window System installed, first look for ucs2any. If you
387 don't, you can download ucs2any.pl from Unicode fonts and tools for
388 X11" (1). This website has much useful information on fonts.
389
390 Another converter is trbdf, included in the "trscripts" package, avail‐
391 able in some GNU/Linux distributions.
392
393 BDF files encoded in ISO 8859-2, ISO 8859-7, koi8-r, etc. are available
394 from ISO 8859 Alphabet Soup" (1) and its sister page The Cyrillic
395 Charset Soup" (1). Though the information is dated, these pages give a
396 good overview of 8-bit character sets.
397
398 To convert OTF or TTF font files to BDF, use
399 otf2bdf by Mike Leisher
400 ⟨http://www.math.nmsu.edu/~mleisher/Software/otf2bdf⟩ .
401
402
403
405 pbmtextps(1), pamcut(1), pnmcrop(1), pamcomp(1), ppmchange(1), pnmro‐
406 tate(1), ppmlabel(1), ppmdraw(1), pstopnm(1), pbm(1), Pango
407 ⟨http://www.pango.org⟩ , Cairo ⟨http://cairographics.org⟩
408
409
411 Copyright (C) 1993 by Jef Poskanzer and George Phillips
412
414 This manual page was generated by the Netpbm tool 'makeman' from HTML
415 source. The master documentation is at
416
417 http://netpbm.sourceforge.net/doc/pbmtext.html
418
419netpbm documentation 01 December 2018 Pbmtext User Manual(0)