Tuesday, December 11, 2012

Pitches and Picas and Points. Oh my!

Except for a few folks who concern themselves with design and printing, most technical writers rarely have to think about things like picas and pitch these days. And few even have much say over point size. And that is a good thing--mostly. Modern word processors use predetermined styles to lay out everything. With technical publishing systems, design and layout is set up in templates. And in structured authoring, content creation is completely separate from output. But in all of these cases, someone is making determinations about stylistic considerations such as line length, even if those determinations generally are built into defaults and are invisible to content authors. Occasionally, it is necessary to jump into a "wayback" machine to figure out what's going on.

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 tags, which allows separate control of code output, and use a monospaced typeface for the output, the width of each character in the code is known. This is where pitch and points come in. (Ok, I confess, pica really has little to nothing to do with this, but it made my title alliterative and gave it the meter I wanted.)

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.
mmmmmmmmmmmmmmmmmmmm
iiiiiiiiiiiiiiiiiiii
In 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.
mmmmmmmmmmmmmmmmmmmm
iiiiiiiiiiiiiiiiiiii
For most standard fixed-width typefaces, you can calculate the pitch if you know the point size. 

120 / points = pitch
The 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 = CPL
In 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.5
Thus, 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.