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