# The Stanford Digital Typography Program

The Preppy Lion has an extensive colophon where I attempt to give credit for all the typefaces used in the book and other design aspects. Among these fonts are the Euler Fraktur and script fonts designed by Hermann Zapf.

I was around when the fonts first came into wide distribution (although I came into the TEX scene just a little after their release—I first started using TEX at the beginning of 1986 while I was still in high school and working part time in the UIC computing center and the fonts were completed in 1985) and I think I might have once had a copy of David Siegel’s monograph on the creation of the fonts although if so, it’s long gone now.

In any event, while trying to dig up information on the typeface to refresh my decades-old memories, I came across this article on the Stanford Digital Typography program. Somehow, in 35 years, I never managed to connect the David Siegel who digitized Zapf’s designs using Metafont¹ with the David Siegel who designed Tekton, among other architectural handwriting–inspired type designs of the 1990s.² In any event, that Stanford Digital Typography program cast a long shadow with its graduates shaping a lot of the typography world of the 80s and 90s.

And all this research? For a footnote that I ended up deleting.

1. Although, while Siegel used Metafont, it is not, strictly speaking, a Meta-font. Each size was created as a separate set of outlines with no parameterization of them at all.
2. Siegel seems to have largely vanished from the typography scene with little or no online presence. The same is true of his classmates Carol Twombly and Neenie Billawalla. Something in the water perhaps?

# Weird xparse tricks

I’m working on another project which provides a LATEX-like typesetting system (but not using TEX for its engine) and I was thinking about how the loading of extensions (its equivalent of LATEX packages) would work.

In particular, I wanted to be able to allow users to do things like

\LoadExtension{ams:amssymb}[\eqcirc -> \eq,\circeq ->\eqcirc]

to enable commands defined in an extension to be renamed at load time.¹ Of course, it would be nice to be able to also do things like give a list of only the commands that should be imported from an extension, or to give a list of commands that should be excluded from the extension.

As I thought about this, I realized that the xparse syntax for argument specifications provides a simple and convenient way to have multiple context-dependent optional arguments. I could define \LoadExtension with an argument template like:

o m o s o s o

The arguments would then be:

1. options to the package (akin to options on \usepackage in LATEX)
2. package name
3. command remappings when all commands are imported
4. * (value ignored)
5. list of commands that should be imported. Only the named commands would be imported.
6. * (value ignored)
7. all commands will be imported except those listed

Then a user could write something like:

\LoadExtension{ams:amssymb}*[\eqcirc]

to import only the \eqcirc command from the extension.

\LoadExtension{ams:amssymb}[\circeq->\ceq]*[\eqcirc]

or even

\LoadExtension{ams:amssymb}[\circeq->\ceq][\eqcirc]

would import two commands, \circeq as \ceq and \eqcirc  Although the user would probably prefer

\LoadExtension{ams:amssymb}*[\eqcirc,\circeq->\ceq]

Using

\LoadExtension{ams:amssymb}[\circeq->\ceq]**[\eqcirc]

would import all the commands except \eqcirc and rename \circeq to \ceq  I’m not sure that this is necessarily better than having something like:

\LoadExtension{ams:amssymb}[rename -> {…}, exclude -> {…}]

as the syntax but it’s interesting to note that xparse allows such things to happen.

1. This particular example doesn’t actually apply for finl. All the AMS symbol fonts will be part of the kernel character set.

# A weird interaction with amsmath

In the LATEX book, I have examples printed side-by-side with their source code. This is managed by setting a pair of \vboxes inside an \hbox inside displayed math so I could take advantage of the display math spacing before and after. While working on the chapter on \newtheorem  I noticed that the cross-reference information was coming out wrong. It was somehow picking up the number of the subsection (the fact that it’s unnumbered and shouldn’t be calling \refstepcounter in the first place is its own issue I need to track down but never mind that for now). After far too long digging into source code (remember, \ShowCommand is your friend), I realized that what was happening was that I was getting the special handling of \label inside display math from the amsmath package. The simple fix was to change the $$ entry into display math to $$$$.

# I should mention the kickstarter on the blog, huh?

For completeness’s sake, I should mention here that I opened a kickstarter for Volume 1 of The Preppy Lion (the LATEX guide for authors). It’s fully funded, but this is a chance to pre-order the book at a lower price than it will be available at post-publication.

# Borrowing accents from a different font

I’m setting the body of my LATEX book in Monotype Ehrhardt. I have a long sentimental attachment to this typeface and I’m on my second purchased copy of the face (I bought it originally in PC Type 1 format and now I have the Opentype version on my Mac). Unfortunately, I decided to cheap out and I didn’t buy the Pro version of the font since I figured I wouldn’t need the Eastern European accents. Oops, it turns out that I do kind of want to have access to hačeks and also the macron accent for a section where I talk about mahāprañāpāramita. But how to get these? Well, the macron accent wasn’t even present in the font, giving a missing character symbol where the accent should appear, so I decided, given its typographic simplicity, that I’d “borrow” it from Latin Modern which I knew had the character.

The thing is, the \accent primitive is a finicky beast. As anyone who’s ever tried to do something like \’{\textbf{a}} would know, you can’t just throw anything inside an accent command. Instead, a more subtle approach is necessary. Thankfully, this already exists thanks to the \t accent. Here’s the definition from plain.tex:

\def\t#1{{\edef\next{\the\font}\the\textfont1\accent"7F\next#1}}

What’s happening here is that TEX saves the current font in the \next macro, changes to \textfont1¹ and issues the accent command and then returns the font to the saved font.² I ended up doing the following in my class file to give me access to the accent from Computer Modern (well, actually Latin Modern).

{\fontfamily{lmr}\selectfont\xdef\thelmrfont{\the\font}}
\def\=#1{{\edef\@tempa{\the\font}\thelmrfont\accent"0304\@tempa#1}}

I could have gotten away with replacing the whole song and dance around \thelmrfont by using \csname TU/lmr/m/n/10\endcsname  but I want the flexibility to adjust the font—I’m already thinking that changing the size to, e.g., 9.5pt might not be a bad idea to make the accent blend better with the provided ñ.

1. \textfont1 is math italic in plain TEX.
2. \the\font or \the\textfont1 expand to the command to load the appropriate font, which under LaTeX will be an otherwise difficult to obtain name like \TU/lmr/bx/n/10.

# Found while digging through my miscellaneous files in the folder for the book

I have the files for The Preppy Lion books in a folder on my hard drive that’s gone through moves from who knows how many computers since around 1990ish and I found a letter to an editor at Springer-Verlag from November 1992 with this gem of a sentence:

Because LATEX 3 is likely to appear in approximately two years, the latter volumes are currently at a low priority.

Also, loads of old stuff for volumes 2, 3 and 5 that I’d forgotten about.

# The pitfalls of Unicode choices for some LaTeX symbols

I had a bit of a shock while looking over a section of my book on typesetting special characters to discover that my example of how to typeset a four-dot ellipsis in LATEX was coming out like:

when I was pretty sure it was supposed to look like:

It was pretty easy to discover that this was because in XeLATEX (and LuaLATEX), \ldots was no longer typesetting spaced dots but using the Unicode … character instead. The appearance, as evidenced above is quite different and the Unicode character doesn’t compose nicely with a following period (as required by some styles, most notably MLA, but some others as well—the example made it into the book originally because it was repeatedly asked about when I was teaching LaTeX classes back in the 80s/90s).

With some digging into source2e.pdf, I turned up \UndeclareTextCommand which lets me undo this. It’s just a matter of adding

\UndeclareTextCommand{\textellipsis}{TU}

to my document class to get the intended result and my ellipses are returned to normal. Unfortunately, I’ll also need to include a mention of this into a sidebar for those who might encounter this edge case on their own.

Update: While writing the text for the book, I discovered that the sequence …. came out almost correct in Monotype Ehrhardt (the spacing is still a little uneven, but not as dramatically so as with Latin Modern), which made it a little complicated to write the sidebar. I had to switch to Latin Modern for those ellipses to illustrate the problem. It looks fine on the blog too. Latin Modern’s ellipsis is broken!

# Is it really wasting time if it seems useful?

I just posted the table of contents of the book on the site, but I ended up spending a day fiddling with things to enable me to print the LATEX logo formatted in the fancy way. For the table of contents, this was pretty straightforward: Add some CSS to the site, and since the table of contents is generated automatically from the .toc file, it’s a simple matter to replace \LaTeX with LATEX (do your own view source to see the ugly details). But then I wanted to put this into the site’s tagline and also in the page title. I spent about a day digging into how WordPress works to find where I could add a PHP function to keep all the ugly HTML/CSS from being printed literally, but then when it came to the page title, I realized I had a new problem. The PHP solution felt fragile to me. So instead, I ended up adding a bit of JavaScript to find the string LaTeX in a page title and replace it with LATEX. A day spent on aesthetics instead of writing.

# Identifying the current font

As I’m working on The Preppy Lion, I was not happy with how the LaTeX logo was being typeset in the main body typeface that I’m using, Monotype Ehrhardt. I decided to make some small adjustments to the spacing and decided that I also wanted to make slight variations if the logo was being typeset in bold or italic or bold italic. The catch was being able to identify what the current font was.

This should be simple. I could simply compare \f@shape to \itdefault or \f@series to \bfdefault. Problem solved right?

So I did the following in my code:

\ifx\f@shape\itdefault
italic code
\else
non-italic code
\fi


and discovered that it didn’t work.


These also weren’t working. I’d done the same \renewcommand magic for \bfdefault but something was still wrong. It appeared that the fontspec package was adding \@empty to the end of the \bfdefault definition.

The old-school way to deal with this would be to write something like:

\edef\next{\bfdefault}
\ifx\f@series\next ...

but this was ugly. It turned out though, while digging through the fontspec code in search of where the \@empty was being added that there was a simpler approach. The expl3 macros provide a way to compare the fully expanded definitions of two macros with the \str_if_eq:eeTF command. I ended up creating two utility macros to handle the checks for bold and italic as:

\DeclareDocumentCommand{\ForIt}{ mm }
{
\str_if_eq:eeTF
\f@shape
\itdefault
{#1}
{#2}
}

\DeclareDocumentCommand{\ForBf}{ mm }
{
\str_if_eq:eeTF
\f@series
\bfdefault
{#1}
{#2}
}


and was able to make my adjustments without difficulty afterwards.

# The quest for a small cap italic i

While working on the manuscript for the book, I noticed that one of my page headings was being rendered as

Putting together a document—part i

thanks to my writing “part I” using a small caps i for the “I.” I was also getting an annoying warning on every odd page:

LaTeX Font Warning: Font shape TU/EhrhardtMTStd(0)/m/scit' undefined
(Font)              using TU/EhrhardtMTStd(0)/m/sc' instead on input line 12.

Monotype Ehrhardt does not have an italic small caps and normally I would shun the use of obliquing against the designer’s wishes but here it was going to be a limited case of a single character which, if it were to exist would be obliqued (in fact, other than losing hinting, there’s not a strong argument against using a mechanical oblique for italic small caps, especially not for a small caps I). The catch was how to persuade fontspec to let me do this.

It took a bit of digging through the documentation of fontspec to figure this out (most of the discussion on the topic on Stack Exchange was to express horror at fake italic small caps), but I eventually managed to get the desired result which I present here for anyone trying to solve this particular problem:

\setmainfont[Numbers=OldStyle,Mapping=tex-text,
ItalicFeatures=
{
SmallCapsFont={Ehrhardt MT Std},
SmallCapsFeatures={FakeSlant=0.2, Letters=SmallCaps}
}
]{Ehrhardt MT Std}