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.

Friday, June 22, 2012

Balancing Act

It is a straightforward equation: Ein = Eout
Energy output must equal energy input in order to maintain balance. Energy input (Ein), which in nutrition is represented in Calories (1 food Calorie = 1 kilocalorie), is the amount of one's "fuel" intake. A kilocalorie is the amount of energy required to raise the temperature of a liter of water 1ÂșC at sea level.
Energy output (Eout) is the total energy expenditure, which is a combination of a person's basal metabolic rate (BMR), the amount of energy used for physical activity, and the thermic effect of food. While the only Eout factor one can reasonably affect is one's level of physical activity, it is the BMR that represents the lion's share of Eout. BMR accounts for 60% - 70% of energy expended. The thermic effect of food (what you burn by eating and digesting food) is nominal, at about 10%.

Behind the curve or curve the behind?

Ahem. And why are women behind the curve in these weighty matters? It largely rests in the BMR calculations.
BMR (males) = (W x 10) + (W x 2)
BMR (females) = (W x 10) + (W x 1)
    where W = weight
An average, 170-pound man burns more than 2000 Calories each day without added exercise.
170-pound male, BMR = 1,700 + (2 × 170) = 2040 
A 170-pound woman burns fewer than 1900 Calories each day without added exercise.
170-pound female, BMR = 1,700 + (1 × 170) = 1870 
Men's bodies have a 9% higher BMR. The fact that men also tend to be denser (speaking strictly in terms of body mass here) and larger than women compounds the problem. So let's look instead at a 120-pound woman.
For a 120-pound woman, BMR = 1,200 + 120 = 1320. Therefore, an average, 120-pound woman can consume only 1,320 Calories without gaining weight.
So women are jilted on BMR.
What other factors affect BMR? First, BMR lessens as we age, and it lessens as muscle mass decreases (and increases as muscle mass increases), which generally occurs as we age. Again, men have an advantage here, as men tend to have larger muscle mass. Then there are some other factors that stack the deck. As if they need it, people who are tall and thin tend to have BMRs that are higher than the average. (Randy Newman may have been right in decrying the plight of "short people.") Stress eating? That is a double whammy, as while more Calories are consumed, mental or emotional stress simultaneously lowers BMR. Fad or temporary diets? They work for awhile, then have the opposite effect, as lower food intake and fasting decrease BMR.

"Let's Get Physical"

Although it may seem like the best way to control weight, exercise and physical activity contributes only 20 to 30 percent to Eout. Furthermore, like BMR, the net effect of physical activity hinges on other factors. Age, sex, height, and weight all figure into how many Calories are burned. A younger, taller, heavier man burns more Calories than a shorter, older, lighter woman. The good news here is that increasing the frequency of activity can have a positive effect. That is, the more active one is, the more Calories one burns for the same amount of activity. Going from inactive to active can increase the daily Calories burned by 21 percent; from moderately active to very active adds another 15 percent.

What is average weight?

There's no such thing. Realistic averages depend on many factors, including age and sex. However, the mean (half more, half less) weight, and, to a lesser degree, the mean height of all women and men is increasing. In the U.S., mean height of adult males increased over 4 decades from 5'8" (1960) to 5'9½" (2002), and mean weight increased from 166 to 191 pounds. For the same time period, female mean height increased from 5'3" to 5'4", and weight rose from 140 to 164 pounds. For women in my age category (I'm not telling, but you can figure it out from the sources), the mean weight in 2002 was more than 169 pounds, a 23 pound (15.5%) increase from 1960. The smaller overall percentage increase in women's weight gain should not be construed as weight gain slowing. Women's cumulative mean weight in all categories leapt more than 6 percent since the 1984-94 survery. Men's increase in the same period was signicantly lower, at 4 percent. This surely is not a good trend for either.

Overweight?

All that good news about men's advantage in weight maintenance? Men in the same age category were 16.5% heavier than in 1960. And while my category topped the charts with a mean body mass indicator (BMI) of 29.2, representing a 10.6% increase over 4 decades, the same age category of men weighed in at 28.7 BMI, a 12.1% increase. Body mass index is a measure of weight with regard to height. A normal BMI is between 18.5 and 24.9. The mean BMIs of 28.7 and 29.2 are considered "overweight," with over 30 being considered obese and over 40, morbidly obese. Because it factors only height and weight, and not lean muscle mass versus fat mass, BMI is not a good indicator for elite athletes, bodybuilders, or children. As I am not currently running daily due to an injury (from a car crash, not from running) and, thus, cannot consider myself an "athlete," BMI is a decent indicator for me. (Again, I'm not telling.) My BMI is on the high side of "normal," which is higher than I would prefer it to be.

And?

For me, reducing Ein simply does not work. I already fast (for religious reasons) several times a year. The only way to keep my BMR up is to not fast or dramatically reduce my caloric intake outside of those fasts. Neither does a flurry of activity at gym provide much benefit. The key for me is to include physical activity throughout my daily routine: take the stairs instead of the elevator, park in the farthest spot rather than the closest one; mow my own lawn. This is a big one, particularly in the heat of a Texas summer. Heat and cold extremes can increase BMR. And sleep. Never underestimate the power of a good night of sleep. Maybe when I advance to PhD candidacy that last one will be achievable. Sources: National Institutes of Health. Teacher's Guide: Information about Energy Balance. http://science.education.nih.gov/supplements/nih4/energy/guide/info-energy-balance.htm. Ogden CL, Fryar CD, Carroll MD, Flegal KM. 2004. Mean Body Weight, Height, and Body Mass Index (BMI) 1960-2002: United States. Advance data from vital and health statistics; no 347. Hyattsville, Maryland: National Center for Health Statistics.