macosfontsjuliagadflyfont-style

How to use different styles of local fonts in plots with Gadfly in Julia-lang on Mac?


I want to create plots with Gadfly in Julia programming language using a specific font style (e.g., Avenir Next Bold) of a local font (Avenir Next) on my Mac. It works for the standard font style in the case of an standard histogram example:

using Gadfly
plot(x=randn(2000), Geom.histogram(bincount=100),
Theme(minor_label_font="Avenir Next",
major_label_font="Avenir Next",
key_label_font="Avenir Next"))

Yet when a specific font style such as "Avenir Next Bold" is used the default font is applied instead of the provided one. The Avenir Next fonts are saved as a "container" in a ttc format. I tried to convert the ttc file into single ttf files for the font styles and to call the exact paths where the files are located. Both don't work.


Solution

  • I think this is a case of getting the font name exactly right.

    gadfly plot

    (I used HeavyItalic because it's easier to tell if the correct font is chosen.)

    It might be that you have to use the PostScript font name, although I'm not sure why that would be, unless deep down in Cairo that's how fonts are accessed... ?

    You can get the PostScript names (if that's what they are) by looking at a font manager. For example, FontBook shows them on the info panel:

    fontbook