7
$\begingroup$

I'm puzzled by FontSubstitutions. The help says this:

FontSubstitutions is an option for Style and Cell that gives a list of substitutions to try for font family names.

I typed this:

Options[Style, FontSubstitutions]

with the result:

Options::optnf: FontSubstitutions is not a known option for Style. >>

OK. So I try the example instead:

Options[$FrontEnd, FontSubstitutions]

and get a list of rules:

{FontSubstitutions -> {"Helv" -> "Helvetica", "Arial" -> "Helvetica",  
 "Times New Roman" -> "Times", "Courier New" -> "Courier",  
 "Lucidabright" -> "Times", "Charter" ->  "Helvetica", 
 "Lucidatypewriter" -> "Courier", "Fixed" -> "Monaco", 
 "AGaramond" -> "Times", "Avant Garde" -> "Helvetica", "Bodoni" -> "Times",
 "Bookman" -> "Times", "Caslon 3 Roman" -> "Times", ...

(Some of these rules are a bit strange - almost like misspellings...)

In the tutorial tutorial/TextAndFontOptions, I read:

In addition, you can set FontSubstitutions to be a list of rules that give replacements to try for font family names.

So my interpretation of this is that, when you supply a string for FontFamily, Mathematica will, on failing to find any kind of matching font for that string, see if there's a rule for it, and then use the equivalent font given by that rule. However, I've not yet managed to make it happen.

Here I try Bodoni. It's not currently active (and the basic face is called Bodoni Book anyway), so it should be substituted by Times. But it appears as Lucida Grande.

Style["The quick brown fox", 60, FontFamily -> "Bodoni"]

font substitutions

and I couldn't get any of the rules to be applied.

I also tried setting a paragraph of text in a particular font (the terrible Dom Casual, which has a rule replacing it with Helvetica), then closing Mathematica, de-activating the font, then re-opening Mathematica and the document. The paragraph's font reverted to ... Lucida Grande.

So, does anyone know how FontSubstitutions works?

$\endgroup$
5
  • $\begingroup$ "so it should be substituted by Times" -- Why? Did you add a rule to that effect? $\endgroup$
    – Mr.Wizard
    Feb 3, 2013 at 15:29
  • $\begingroup$ it's further down the list of rules - there are 142 of them. I'll fiddle with the list a bit... :) $\endgroup$
    – cormullion
    Feb 3, 2013 at 15:33
  • 2
    $\begingroup$ @cormullion You may find it easier to experiment with FontSubstitutions by using the selector syntax form for options like this: CurrentValue[$FrontEnd, {FontSubstitutions, "Bodoni"}] . You can also use assign values by putting the CurrentValue expression on the left-hand side of an equal sign. $\endgroup$
    – John Fultz
    Feb 4, 2013 at 1:27
  • 2
    $\begingroup$ @cormullion And yes, I can reproduce your problem with the Mac v9 version (I think it works elsewhere). It does look like FontSubstitutions is not working correctly on Mac. $\endgroup$
    – John Fultz
    Feb 4, 2013 at 1:28
  • $\begingroup$ Seems like it works as it should on Windows (9.0.1), except that the first time the substitution is employed, it gets "stuck"--subsequent changes to the CurrentValue have no effect. Must be cached somewhere? $\endgroup$ Feb 4, 2013 at 2:22

1 Answer 1

3
$\begingroup$

In Mathematica version 10, this now works on Mac OS X.

For example, this rule is part of the system-supplied FontSubstitutions list:

"Meridien" -> "Times"

So when you type in the font name either incorrectly or if the system can't find a font with that name:

Style["The quick brown fox", 80, FontFamily -> "Meridien"]

you see the designated substitution:

font substitution in action

Then, if you activate the font, or type its name correctly:

Style["The quick brown fox", 80, FontFamily -> "Meridien LT Std Roman"]

you see the correct font:

font substitution not required

Thanks John Fultz!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.