Skip to content

Instantly share code, notes, and snippets.

View matteoacrossi's full-sized avatar

Matteo AC Rossi matteoacrossi

View GitHub Profile
@alexrudy
alexrudy / matplotlib-fonts-osx.md
Last active July 12, 2022 13:16
Adding custom fonts to Matplotlib on OS X

How to add custom (or system) fonts to matplotlib on OS X

Matplotlib expects to find .ttf fonts on your system. Newer versions of OS X use .dfont files. Converting them is easy, and putting them in a proper font path is also easy. The user font path on OS X is ~/Library/Fonts/, and matplotlib will find fonts here.

  1. First, install what you'll need:
  • matplotlib
  • fondu (port install fondu, or brew install fondu)
  1. Then find your desired font file. For system font files, the easiest way to do this is in the FontBook application. You can open FontBook in your utlities folder. Then select your font of choice, right click on it, and select "Show in Finder". You'll need to know where it is. Many system fonts are in places like /System/Library/Fonts/...
  2. Move to your user's font directory ~/Library/Fonts/.
  3. Use fondu to convert the OS-X specific font file (ends with .dfont) to .ttf.