Summary: Aligning Text in Mathematica
Finding the Font Data by Trial and Error
Michael P. Barnett
June 2, 2010
I measure the widths of characters very easily. The command fontWidthDisplay["Symbol", 1] produces
the file widthDisplay_Symbol_1.pdf that represents Fig. 1. Each line is the concatenation of 40 copies of a
character in 10 point Symbol font. The 40 s end on the vertical grid line that is labeled 5.5. This corresponds to
a single being 5.5 points wide. The and have the same width. Close approximations to the widths of other
characters can be read from this display. A method to refine these is described below. Fig. 1 contains the lower and
upper case letters.
The command fontWidthDisplay["Symbol", 2] produces the corresponding display for the remaining
41 characters that each has its own key on a standard PC keyboard. The final line in this second display has a | at the
right of a line of 40 letter spaces. Other font names can be used in place of Symbol. When a hyphen is present, as in
Times-Roman, it is elided in the construction of the file name. The widths are saved in the file tmgTables/widths.
This consists of a SetDelayed statements that has a Switch expression as the right hand side, for each non-uniform
width font. The statement for Times-Roman is typical.
characterWidth["TimesRoman", v_String] /; StringLength[v] == 1 :=