Bug introduced in OSX v10.0.0 and persisting in all v10.x.x. Almost fixed in v11.0.0

I‘m using stylesheets to create customized styles for course materials. That includes using fonts like Gill Sans, and Helvetica (Neue).

Up to MMA version 9, it worked. When switching to version 10, especially light/thin fonts were no longer displayed correctly and error messages like "The specified setting for the option FontWeight cannot be used." appeared when using my version 9 stylesheets.

Then, I realized that font options changed in Version 10, that is using the front end -> Format-> Show Fonts... -> Modern -> Helvetica Neue now lists a couple of new options. However none of them seem to work as expected (trying just to format a text). I basically get Regular for all modern fonts in all cases.

Here is the code as I intend to use it to create styles:

  Table[Cell["Test", "Text", FontFamily -> "Helvetica Neue", 
    FontWeight -> fw, FontSize -> 20],
      {fw, {"Regular", "Medium", "Light", "Thin", "UltraLight", "Italic", "Medium Italic",
            "Light Italic", "Thin Italic", "UltraLight Italic", "Bold Italic", "Condensed Bold",
            "Condensed Black"}}]

And the corresponding output: output

How can I use the FontWeight options as listed in the menu?

My configuration: Mathematica (when updating from version 9, I deleted the old Mathematica installation and the folder ´Mathematica´ from the Library) Mac OS X 10.10.2

  • $\begingroup$ Given SquareOne's reasonable and lacking any evidence to the contrary I am tagging this as a bug. $\endgroup$ – Mr.Wizard Aug 9 '15 at 5:33
  • $\begingroup$ At least FontWeight -> "Bold" still seems to work. Somehow Mathematica is re-orgainizing the dfont contents, and losing information. But FontSlant still works. Combinations like "Bold Italic" are neither pure weight nor pure slant information, and maybe that's why they get ignored... $\endgroup$ – Jens Aug 9 '15 at 6:18
  • $\begingroup$ @Jens That is strange, the font panel does not let me change directly the font weight or slant for some "basic" fonts (Arial, Verdana, Optima, Chalkboard, Gill sans, ...). For example I cannot display some simple Arial Bold (actually it remains Plain whatever style I click on). At least (as you say) it works if I do Style["Hello",20,Bold] and if I select the output, it is correctly highlighted in the font panel ... $\endgroup$ – SquareOne Aug 10 '15 at 19:57
  • $\begingroup$ @SquareOne Indeed - the font panel that gets pulled up on the mac when pressing Apple-T is a "system specific panel", not created by Mathematica. It directly mirrors the structure of the font files as they are actually installed. But if you invoke the shortcuts Apple-B or I to change the style, you get the expected behavior. It's definitely a bug because you're really losing a lot of the styles that aren't derived from the base font simply by boldfacing or italicizing it. Those other styles probably could be extracted from the system dfont files and installed as separate fonts to be visible. $\endgroup$ – Jens Aug 10 '15 at 20:51

Update: version 11.0.0 (OSX problem only)

There is a big improvement: it seems possible again to display all(?) the fonts available in the system. However, it is not always straightforward to do so because you have to find out how to combine different font options to display a given typeface.

Here are see some examples, I'll stick with the "Helvetica Neue" family where for example 14 different typefaces (Regular, Medium, ..., Bold, ..., Ultralight Italic, ..., Condensed Black, Condensed Bold) are available (at least in my system font panel).

=> For example to display the "Ultralight Italic" typeface (the official name which appears for me in the OSX system font panel), this is rather easy, you have to combine two font options (for the weight and slant):

Style["Hello", 40, FontFamily -> "Helvetica Neue", FontWeight -> "UltraLight", 
FontSlant -> Italic]

enter image description here

Remark though that "UltraLight" is not an officially listed FontWeight (not listed in the dynamic command line menu nor in the docs (see the Details section).

=> But what about the "Condensed Black" typeface listed in the system panel ? Here you'll just have to omit the "Condensed" part and set FontWeight->"Black". Interestingly if you add the option FontSlant->Italic, you'll get indeed an italicized condensed black font, which does not officially exist in the system fonts ...

enter image description here

enter image description here

=> Now, I didn't succeed in displaying the typeface "Condensed Bold" by trying various settings with the usual font options (FontWeight and FontSlant)...

However, I was able to convert some ordinary cell text into this typeface using the system font panel (press Apple(cmd)+T). Then applying Show Expression on this cell, this finally revealed another font option and its setting to display the given typeface:

Style["Condensed Bold", 40, FontFamily->Automatic, FontWeight->"Bold",

enter image description here

=> The question then is if each font can be displayed using the sole PrivateFontOptions option ? Repeating the previous Show Expression procedure on a "UltraLight Italic" text, did not however show any PrivateFontOptions at all ... Then, I just tried by hand by concatenating the typeface name as in the previous "Condensed Bold" case and it worked:

Style["Hello", 40, FontFamily->Automatic,

enter image description here

The PrivateFontOptions option seems to be an interesting way to directly (one option setting only) select and display a given font family with its typeface (as was the case in v.9) instead of combining different options. The question is how to get automatically the whole list of the settings corresponding to each system font ? Does it work for all the fonts ?

Previous 10.x.x versions

new in v10.0.1 : $FontFamilies gives directly the list of available fonts

It seems indeed that v10 (OSX) is not anymore able to display all the fonts typefaces available on the system, whereas v9 is.

You can easily check that using directly the font panel (Menu : "Format -> "Show Fonts ..."). Select some text in the notebook, and try to modify its FontFamily and Typeface. For example choose the font family "Helvetica Neue" and select the different typefaces "thin", "light" ... Nothing changes in v10, whereas in v9 the style of the selected text changes in agreement to what is displayed in the font panel.

Here is an example with v9 :

enter image description here

"Strangely", the cell expression ("Cell"->"Show Expression") corresponding to the last text example shows that for Mathematica v9 the corresponding font family is "Helvetica Neue UltraLight" (but this font family does not exist in the system font panel list) ... Using directly this font family name ("Helvetica Neue Ultralight") to display some text works with v9 but does NOT work with v10 !

Here is the same example in v10
(this corresponds to the same v9 notebook example than above but just rendered with v10).

enter image description here

We can check indeed that the v9 and v10 fonts list are not the same :

fontlist = 
  FE`Evaluate[FEPrivate`GetPopupList["MenuListFonts"]][[All, 1]];

and for example :

StringCases[fontlist, "Hel" ~~ __ ~~ "Neu" ~~ __] // Flatten // InputForm

returns in V9 :

{"Helvetica Neue", "Helvetica Neue Black Condensed", "Helvetica Neue Bold Condensed", "Helvetica Neue Light", "Helvetica Neue Medium", "Helvetica Neue Thin", "Helvetica Neue UltraLight"}

returns in V10 :

{"Helvetica Neue"}

  • $\begingroup$ Support for Webdings was dropped in V10 so maybe it is related to that. V10 is still very much a work in progress it seems. Hopefully we can have a 10.0.3 and a 10.0.4 soon. $\endgroup$ – Mike Honeychurch Feb 10 '15 at 1:58
  • $\begingroup$ Have you tried using Style["some random text", FontFamily -> "Helvetica Neue", FontWeight -> "UltraLight"] instead? $\endgroup$ – ihojnicki Feb 10 '15 at 3:39
  • $\begingroup$ @ihojnicki Yes i did that test, FontWeight->"UltraLight" or replacing "UltraLight" by other typefaces (as the OP did) do not work with Style. (The OP tested that with Cell then CellPrint) $\endgroup$ – SquareOne Feb 10 '15 at 10:44
  • $\begingroup$ Do you think this question should be tagged as a bug? Your presentation makes me think it should. $\endgroup$ – Mr.Wizard Aug 8 '15 at 10:39
  • $\begingroup$ @Mr.Wizard Given that this was working in V9, yes I would consider this persisting "regression" as a bug. The user -ihojnicki- which commented also this post seems to work for WRI but did not comment anymore on this ... By updating this post i hoped someone else would. As -mike honeychurch- said, maybe it is somehow related to the Webdings problem (which is tagged as a bug.) $\endgroup$ – SquareOne Aug 8 '15 at 20:06

Observations pertain to Mathematica 10 under Windows.

It seems that at least with certain fonts the font weight (or variation) needs to be specified as part of the FontFamily rather than the FontWeight.

Using code from How to find out available fonts from within Mathematica?:

fontlist = FE`Evaluate[FEPrivate`GetPopupList["MenuListFonts"]];

selection = Pick[#, StringMatchQ[#, "*Neue*"]] & @ Keys @ fontlist

Style["Mathematica Stack Exchange", FontFamily -> #, 20] & /@ selection // Column
{"HelveticaNeue BlackCond", "HelveticaNeue BlackExt", "HelveticaNeue BoldOutline",
 "HelveticaNeue Condensed", "HelveticaNeue ExtBlackCond", "HelveticaNeue Extended",
 "HelveticaNeue LightCond", "HelveticaNeue LightExt", "HelveticaNeue MediumCond",
 "HelveticaNeue MediumExt", "HelveticaNeue ThinCond", "HelveticaNeue ThinExt",
 "HelveticaNeue UltraLigCond", "HelveticaNeue UltraLigExt"}

enter image description here

  • $\begingroup$ I confirm, this used to work the same way with OSX and v9, but not with v10 anymore (only 1 font is returned by fontlist, see my post) $\endgroup$ – SquareOne Feb 10 '15 at 12:45
  • $\begingroup$ @SquareOne Perhaps the question should be tagged osx in that case? $\endgroup$ – Mr.Wizard Feb 10 '15 at 13:28
  • $\begingroup$ I tagged it as OSX. $\endgroup$ – SquareOne Feb 10 '15 at 17:00
  • $\begingroup$ Now in V10.1 there is $FontFamilies constant. $\endgroup$ – Murta Apr 1 '15 at 21:02
  • 1
    $\begingroup$ The variations are not available. While CellPrint[ Cell[Style["Hello, Mathematica!", FontFamily -> "Helvetica Neue"], "Text"]] works, CellPrint[ Cell[Style["Hello, Mathematica!", FontFamily -> "Helvetica Neue", FontWeight -> "Thin"], "Text"]] does not, nor does the corresponding expression with "Bold" in place of "Thin:. $\endgroup$ – murray Nov 11 '15 at 19:35

MaTeX to the Rescue

As of version 11.3, Mathematica's handling of font variations is still buggy. To address the need for displaying text objects in any font correctly and using them to compose graphic objects that can be converted to PDF without losing their formatting, I turn to MaTeX. It might seem overkill, but it allows you to bypass the font bug completely.

To be able to use any font installed in your system, you would need to use the XeLaTeX mode (with the path set as appropriate for your system):

ConfigureMaTeX["pdfLaTeX" -> "/Library/TeX/texbin/xelatex"]

with fontspec + unicode-math in the base preamble:

  "BasePreamble" -> {"\\usepackage{fontspec,unicode-math}"}

or mathspec (which also loads fontspec so you don't have to declare it):

  "BasePreamble" -> {"\\usepackage{mathspec}"}

Choosing between them is beyond the scope of this answer. (See for example here as a starting point.) In brief, if you'd like to use a non-math font in the math mode, go for mathspec.

With either one of them chosen as the base preamble, we could construct a function that formats a string in any font of any size as follows, provided you know the name (not the PostScript name) of the font of the desired variation:

text[txt_, font_, size_] := MaTeX[
  "\\text{" <> txt <> "}",
  "Preamble" -> {"\\setmainfont{" <> font <> "}"},
  Magnification -> size / 10

For example:

text["Hamburgefonstiv 2018", "InputMonoCondensed MediumIta", 40]

Hamburgefonstiv 2018

You can obtain Input Mono to try this yourself from here.

The approach allows me to for example produce a PDF figure below, typeset in two variations of ITC Conduit. Without it, exporting the plot (directly with "Save Graphic As", or through this, or through Jens's gsExport) only results in the text pieces falling back to Helvetica and frustration.

Hamburgefonstiv 2018

Bonus: Font Test

Let me share the following code to illustrate the font bug.

fonttest[family_, weight_, slant_, postscriptname_] := Module[
  {sizes, text, head, list, n, g, s, p, private, c},
  text = "Hamburgefonstiv 2018";
  sizes = Range[20, 30, 10];
  private = PrivateFontOptions -> {"FontPostScriptName" -> postscriptname};
  c = Apply[RGBColor] /@ ({{27, 163, 142}, {252, 161, 36}, {220, 74, 74}, {30, 33, 40}} / 255);
  list[x__] := (
    Print["As Notebook Texts:"];
      Print @ Style[text, FontSize -> size, x],
      {size, sizes}
    Print["As Graphics Objects:"];
      Print @ Graphics[Text @ Style[text, FontSize -> size, x], ImageSize -> {size StringLength[text], 1.5 Max[sizes]}],
      {size, sizes}
  head[t1_, t2_, t3_] := Print @ g[
      s["Family: " <> n[t1]],
      s["Weight/Slant: " <> n[t2]],
      s["PS Name: " <> n[t3]]
    {None, None, {{1, 1} -> c[[1]], {1, 2} -> c[[2]], {1, 3} -> c[[3]]}}
  g[cont_, bg_] := Grid[cont, Background -> bg, Frame -> All, FrameStyle -> White, Spacings -> {2, 1}];
  s[txt_] := Style[txt, Larger, White, Bold];
  n[state_] := Switch[state, -1, "Auto", 0, "-", 1, "Specified"];
  p[txt_] := Print @ g[{{s @ txt}}, c[[4]]];
  p["Compare the samples below with a correct specimen of " <> postscriptname];
  head[-1, 0, 1];
  list[FontFamily -> Automatic, private];
  head[-1, 1, 1];
  list[FontFamily -> Automatic, FontSlant -> slant, FontWeight -> weight, private];
  head[1, 1, 0];
  list[FontFamily -> family, FontSlant -> slant, FontWeight -> weight];
  head[1, 0, 1];
  list[FontFamily -> family, private];
  head[1, 1, 1];
  list[FontFamily -> family, FontSlant -> slant, FontWeight -> weight, private];
  p["Export a Graphics Object to PDF to see if what works on screen still works in print"];

The arguments of fonttest are:

  1. The base name of the font to test
  2. The value that would be for FontWeight were you to attempt to use the font
  3. The value that would be for FontSlant were you to attempt to use the font
  4. The PostScript name of the font

For example:

fonttest["Input Mono", "Thin", Italic, "InputMono-ThinItalic"]

The function helps you examine whether styling a string with the following methods works, in a Cell environment and Graphic environment:

1 (Minimal Specification)

  FontFamily -> Automatic,
  PrivateFontOptions -> {"FontPostScriptName" -> ...}


  FontFamily -> Automatic,
  FontWeight -> ..., FontSlant -> ..., 
  PrivateFontOptions -> {"FontPostScriptName" -> ...}

3 (Normal Specification)

  FontFamily -> ...,
  FontWeight -> ..., FontSlant -> ...


  FontFamily -> ...,
  PrivateFontOptions -> {"FontPostScriptName" -> ...}

5 (Maximal Specification)

  FontFamily -> ...,
  FontWeight -> ..., FontSlant -> ..., 
  PrivateFontOptions -> {"FontPostScriptName" -> ...}

All sample sets should look identical, or at least the discrepancies between them should be consistent across multiple fonts. Neither seems to be the case. Here's my result, on Mathematica 11.3 on macOS High Sierra, with Input Mono Thin Italic.

fonttest["Input Mono", "Thin", Italic, "InputMono-ThinItalic"]

Font Test

So many things are not right, not to mention when the pieces are exported to PDF.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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