7

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?

cormullion
  • 24,243
  • 4
  • 64
  • 133
  • "so it should be substituted by Times" -- Why? Did you add a rule to that effect? – Mr.Wizard Feb 03 '13 at 15:29
  • it's further down the list of rules - there are 142 of them. I'll fiddle with the list a bit... :) – cormullion Feb 03 '13 at 15:33
  • 2
    @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. – John Fultz Feb 04 '13 at 01:27
  • 2
    @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. – John Fultz Feb 04 '13 at 01:28
  • 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? – Oleksandr R. Feb 04 '13 at 02:22

1 Answers1

3

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!

cormullion
  • 24,243
  • 4
  • 64
  • 133