After not thinking about line length for quite some time, the topic came up today when I was asked about line wrap behavior for code blocks shown in documents. A "line" in code may be much longer than what can be displayed across one line on a page. Even when output is online only, it may be undesirable to show a long code line in a single line on the screen that requires the reader to scroll to the end. In this particular case, we decided that we would set a maximum at which the system will send a message notifying the content author that a code line will wrap in the output so that the content author can determine how to handle it. But in order to set up this threshold message, the tools developer needed to know how many characters would fit on a line in output.
In this case, it was a fairly straightforward calculation (once I was in "way back thinking" mode). First, because most of the customer output is to PDFs, which have a set size and "image area," the maximum line width is known. Second, because we mark all blocks of code with
What is the relationship between pitch and points?
Points (or point size) comes from typesetting. A point equals 1/72 of an inch. The point size of a typeface measures the height of its characters. (Points is also used to express the amount of space between lines--the leading [led'-ing].) Pica, by the way, is used in typesetting but rarely in computer typography. A pica is 12 points (1/6 inch).Pitch in typesetting is shorthand for per inch. The pitch of a typeface is the width of its characters, expressed as the number of characters that fit into an inch. These calculations are based on fixed-width, monospace typefaces. Although the calculations work in general for proportional typefaces, keep in mind that characters are different widths in proportional typefaces; an m (for example) is much wider than an i. Taken another way, a line of 20 m's in a proportional typeface is longer than a line of 20 i's.
mmmmmmmmmmmmmmmmmmmmIn a monospace typeface, all characters take up the same amount of horizontal space, so the calculation works regardless of the content, i's or m's or other characters.
iiiiiiiiiiiiiiiiiiii
mmmmmmmmmmmmmmmmmmmmFor most standard fixed-width typefaces, you can calculate the pitch if you know the point size.
iiiiiiiiiiiiiiiiiiii
120 / points = pitchThe most commonly-used typeface sizes, 12 and 10 points, are easy: 12pt = 10 pitch and 10pt = 12 pitch.
You also need to know how much space is available.
How many characters will fit on a line?
If you know the pitch of the (monospaced) typeface and the maximum width of that output (the image area), you can calculate the maximum characters per line (CPL) using this formula.pitch * image area inches = CPLIn my example today, we use 8 point output for code blocks and we have a 6.5-inch image area.
120 / 8 = 15
15 * 6.5 = 97.5Thus, the maximum number of characters before a code line wraps is 97. The tools developer can set the message threshold to 97 to kick off a message to inform a content author that a code line will autowrap.
Caveat: This is a simplistic presentation of points and pitch that does not consider things such as kerning adjustments and non-standard typefaces. Nonetheless, for many issues in computer typography such as the one presented here, these simple calculations are sufficient.