Skip to content

Instantly share code, notes, and snippets.

@Axlefublr
Created September 29, 2024 14:23
Show Gist options
  • Save Axlefublr/c243807d2c50e6cf8b02c21da4cf8493 to your computer and use it in GitHub Desktop.
Save Axlefublr/c243807d2c50e6cf8b02c21da4cf8493 to your computer and use it in GitHub Desktop.

Add the ttf of the font you want into ~/.local/share/Anki2/User 1/collection.media.
Rename it so it has the underscore before the name (this ensures "check empty media" doesn't delete it).
Put this in the CSS of the note where you want to use this font:

@font-face {
  font-family: InputMonoGrafted;
  src: url("_InputMono-Regular.ttf");
}

It should be at the bottom; apparently as the absolute last thing in your CSS.
InputMonoGrafted is your own name for the font, which is how you're gonna refer to it.
In the url, specify the path, relative to collection.media.

Now you can sync from the computer, then sync from the phone, and you'll see phone use the correct font now.

To add multiple custom fonts, just add a @font-face block per each of them.
I tried adding _Inter_28pt-Regular.ttf, but it didn't work, probably because 28 is too big; worked with 18 though. So that may be a factor.

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