I completely spaced the ICM homework last week, which is sad, because it involved a language I actually have some experience with: PHP. I know just enough about it to fiddle with WordPress templates—and once, in 2002 or so, I spent a few days trying to rebuild the ColdFusion-backed in PHP, just for kicks.

Yeah, I didn’t get very far with that, but it’s the thought that counts.

Last week’s assignment was to

Using HTML and PHP, create a page which contains a form for some kind of (census, survey?) data collection and a second page which tallies up and displays the results (perhaps use Processing for visualizing the results

Easy peasy. I mean, not that this is stuff I can do off the top of my head—HTML forms are one of the many things I rarely have occasion to create from scratch, so I’ve never gotten enough practice at it to not have to look up the syntax for every single type of control—but it’s certainly stuff I’ve done dozens of times. So on Friday, while I was waiting for it to be time to go to a party, I started putting together a little cast-off calculator.

Casting off, for those who do not work in publishing, is the process of figuring out how long a typeset book will be, based on its typed or word-processed manuscript. It can be surprisingly accurate, when one has reliable character-per-pica (CPP) charts with which to estimate the volume of the typeset page. This problem is, of course, that there are a zillion factors that can affect the CPP. Which font are you using—that is, which typeface, and in which size? You have to be very specific about this. Just saying “Garamond 9” won’t do; you need to know which Garamond—Adobe? Postscript or OpenType (or metal, or photoset)? The old Adobe Garamond, or the new Adobe Garamond Premier Pro? What typesetting program are you using—InDesign CS3, Quark XPress 4.11, PageMaker 6 Win, Pages? LaTeX? What H&Js are you using? Does the text use a lot of italics? Blah, blah, blah.

So, this calculator is actually pretty useless, because the CPP figures for my various font options are pulled from a couple of sources, none of them good. Somewhere I have a real list of CPPs from Westchester, a major U.S. typesetter, which I know are reliable . . . for the conditions under which Westchester was setting books for me at the time: Quark XPress 4 or 5, PostScript fonts, fixed H&Js, etc. Somewhere I also have a more detailed, and therefore accurate, cast-off formula that takes into account the number of chapters and parts a book has, and how much front or back matter there is. Maybe later I’ll update this code to reflect those real-life samples. For now, though, it gives you the basic gist: you plug in some numbers, you get some numbers back.

The input form—adapted from an example in the Chicago Manual of Style (Fig. A.4)—is okay, but the output page is quite nasty so far. Not sure what’s the best way to present all that information, so for now I’ve just left it where the PHP flang it.

Try it out: Cast-off Calculator

The PHP portion is as follows:

$chars_per_line = $_GET['chars_per_line'];
$lines_per_page = $_GET['lines_per_page'];
$ms_page_count = $_GET['ms_page_count'];
$total_ms_chars = $chars_per_line * $lines_per_page * $ms_page_count;

list($font, $cpp) = split(";", $_GET['typeface'], 2);
$measure = $_GET['measure'];
$depth = $_GET['depth'];
$total_page_chars = $cpp * $measure * $depth;
$chars_tight = round($total_page_chars * .9);
$chars_loose = round($total_page_chars * 1.10);

$castoff = round($total_ms_chars / $total_page_chars);
$pages_tight = round($castoff * .9);
$pages_loose = round($castoff * 1.10);

echo "<p><b>Characters per line:</b> " . $chars_per_line . "<br />
&times;<br />
<b>Lines per page:</b> " . $lines_per_page . "<br />
&times;<br />
<b>Number of manuscript pages:</b> " . $ms_page_count . "<br />
=<br />
" . number_format($total_ms_chars) . " total characters in manuscript</p>
<p><b>Font:</b> " . $font . "<br />
<b>Characters per pica:</b> " . $cpp . "<br />
&times;<br /><b>Picas per line:</b> " . $measure . "<br />
&times;<br />
<b>Lines per typeset page:</b> " . $depth . "<br />
=<br />
" . number_format($total_page_chars) . " total characters per typeset page<br />
<b>Tight:</b> " . number_format($chars_tight) . "<br />
<b>Loose:</b> " . number_format($chars_loose) . "</p>
<p>Characters in manuscript ÷ characters per typeset page =<br />
<b>Normal:</b> " . number_format($castoff) . " pages &#8594; " . floor($castoff / 8) . " &times; 8 + " . bcmod($castoff, '8') . " pages<br />
<b>Tight:</b> " . number_format($pages_tight) . " pages &#8594; " . floor($pages_tight / 8) . " &times; 8 + " . bcmod($pages_tight, '8') . " pages<br />
<b>Loose:</b> " . number_format($pages_loose) . " pages &#8594; " . floor($pages_loose / 8) . " &times; 8 + " . bcmod($pages_loose, '8') . " pages</p>";

Photo: Auto Setter by Marion Doss; some rights reserved.

One thought on “PHPhun”

Leave a Reply

Your email address will not be published. Required fields are marked *