This article originally appeared in TidBITS on 2012-08-14 at 12:43 p.m.
The permanent URL for this article is:
Include images: Off

Fix Your Fonts in Safari 6

by Michael E. Cohen

As those who have installed Safari 6 (which comes with OS X 10.8 Mountain Lion) have discovered, the capability to set the browser’s default proportional font and the default fixed-width font has vanished from Safari’s preferences. As a result, some sites — specifically those that don’t set their own fonts using CSS (Cascading Style Sheets) — have begun appearing in Times and Courier, regardless of the default font settings a user may have set in a previous version of Safari.

Two solutions are available. The first is for users to create a default CSS file that Safari can use. This document, a text file with the file extension .css, can be stored anywhere; users simply need to point to it from the Style Sheet setting in Safari’s Advanced preferences. The contents of such a CSS document might look something like this:

body { font-family: "Lucida Grande"; }
code, tt { font-family: "Consolas"; font-size: 90%; }

With the style sheet in place, after Safari is quit and relaunched it uses the specified fonts for body text and code text if a page’s HTML and CSS don’t specify otherwise.

However, one can also set Safari’s default fonts with shell commands using Terminal. Even though the user interface for setting these defaults has vanished, Safari still has them. The magic shell command is defaults and it takes four uses of it to set the defaults that one formerly set in Safari’s preferences. All one needs to do is open Terminal and issue the appropriate commands on the command line, and then quit and relaunch Safari.

For example, here is how I set my default fonts to Lucida Grande (proportional) and Consolas (fixed-width). First is the command to set the proportional font family (each of these is a single line):

defaults write 'Lucida Grande'

Next is the command to set that font’s default size:

defaults write 14

Then one issues a similar command for the fixed-width font:

defaults write 'Consolas'

And another for the fixed-width font size:

defaults write 11

Granted, opening Terminal and pasting esoteric commands instead of using a graphical interface is not a usability win, but at least you need not be forced to view Times when you want Lucida Grande!

(A brief aside. I like to tweak how pages look, so although I can use Terminal to try out different default font and size combinations, I have found it more convenient to make a TextExpander shell script snippet [1] that I can use to set and reset font defaults. The shell script snippet uses the same syntax as the Terminal commands but can be edited and invoked far more quickly. Plus, it makes a satisfying “pop” sound when it’s done.)