Skip to content

Instantly share code, notes, and snippets.

@javan
Created June 11, 2019 19:37
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save javan/ececf9e2ef9bd4267b15717e657110bf to your computer and use it in GitHub Desktop.
Save javan/ececf9e2ef9bd4267b15717e657110bf to your computer and use it in GitHub Desktop.
Add SF Mono to Firefox (macOS only)

GitHub uses the following CSS font stack to display code:

font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace;

Chrome will use SFMono-Regular when that font is installed locally, but Firefox will not. Workaround: Add the following CSS to your Firefox profile's userContent.css file:

@font-face {
  font-family: SFMono-Regular;
  src: local("SFMono-Regular");
}
Before After
ff-before ff-after
#!/usr/bin/env bash
set -e
FF_DIR="$HOME/Library/Application Support/Firefox"
PROFILE_PATH=`grep "Default=" "$FF_DIR/profiles.ini" | sed "s/Default=//"`
PROFILE_CHROME_DIR="$FF_DIR/$PROFILE_PATH/chrome"
CSS_FILE="$PROFILE_CHROME_DIR/userContent.css"
mkdir -p "$PROFILE_CHROME_DIR"
cat << EOF >> "$CSS_FILE"
@font-face {
font-family: SFMono-Regular;
src: local("SFMono-Regular");
}
EOF
echo "Done! Added the following CSS to $CSS_FILE"
echo
cat "$PROFILE_CHROME_DIR/userContent.css"
@javan
Copy link
Author

javan commented Jun 11, 2019

👆
👇

$ curl -Ls https://git.io/fjgMq | sh
Done! Added the following CSS to /Users/javan/Library/Application Support/Firefox/Profiles/t9kabcx4.Javan/chrome/userContent.css

@font-face {
  font-family: SFMono-Regular;
  src: local("SFMono-Regular");
}

@cuongnguyen0527
Copy link

For new versions of firefox, remember to set toolkit.legacyUserProfileCustomizations.stylesheets to true.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment