Make a Custom Font Selector Settings

Anki now has a very complicated way of changing fonts in cards.

I suggest an extra option that allows setting custom fonts in your cards without having to touch code.

The way I’m imagining it would also allow Anki cards to have different fonts in different platforms without having to use extra user-facing code in styling. And of course, users can override the global setting by changing the code in styling.

Obsidian does something similar where you can set a single font from their setting which will be used everywhere in your notes. And AnkiDroid used to do it too until recently when they removed it.

Just thinking aloud: Maybe the setting you mentioned could be applied in the already existing code instead:

.card {
    font-family: arial;
    font-size: 20px;
    text-align: center;
    color: black;
    background-color: white;
}

arial could be a css variable, which would be modified by the setting you propose.

Problems with your proposal

  1. The font settings would still need to be synced. If it’s not exposed in the templates, then it would be synced differently.
  2. Not exposing it in the templates could cause confusion.
  3. Not exposing it in the templates causes less flexibility (basically everything would be that one single font. You couldn’t, for example, set a specific font for headers and another font for body text).
  4. Somehow, fonts would need to be managed: a) would Anki insert a link to the font and always download the font front the internet? b) would Anki use a locally stored file (where did anki get this file from)? c) would anki use fonts that are available on the current computer / smartphone (what if it’s not available? Would we just use the OSes default fallback font, which might be too different from the font the user intially selected)?

I personally don’t think adding a custom font is difficult – I did that on my template as well, using the official instructions in the manual (Styling & HTML - Anki Manual). It was pretty easy.

Though I admit that I felt a bit intimidated by it at first – which is why it was a great relieve to see that the manual is so easy to understand in this regard. And it’s also the reason why I generally agree with you that font handling could be improved somehow.

Maybe it could be done as part of Consider a cross-platform add-on system for templates · Issue #3833 · ankitects/anki · GitHub?

1 Like

That’s the idea. I was sort of prompted by the combined effect of this post (where we tried to have different fonts for different platforms) and seeing Obsidian do it.

As I said, AnkiDroid also had this setting (which they removed :feels-sad-anki:) so we have a precedent for this. And users liked it too so AD is planning to bring this back. So, with that logic I’m simply proposing what AD will do anyway.

As you said, the setting can simply modify a variable in the template.

No, the suggestion is you should be able to change fonts. In AnkiDroid too, that’s how the feature was designed.

For starters, we can simply ship Anki with fonts for different languages.


It took me like a few days of back and forth with people in discord to sort out my custom font issues which is also why I joined the server in the first place. Well, I couldn’t find the custom font section of manual so…

Maybe, that works too I am not sure.

You mean I could set a font for everything I want separatly? Font A for h1, font B for h2, Font C for h3, Font D for Body, Font E for code blocks…? If yes, then the setting must be really complex – which makes me wonder if it’s actually an improvement compared to the current, simple css solution.

And yes, I know that this many fonts isn’t best practises when it comes to website dev (and anki cards are just webpages) – my point is that this should be supported.

I’m strongly against this. Why would we ship fonts (which probably would also be an issue due to licenses), if every single operating system has multiple fonts already, including a fall back to the most similar of the available fonts?

It would clutter anki (in a bloatware sense) and doesn’t really help anyways. Most default fonts are available on every platform. Which means if the user wants to change the font to something their OSes don’t have yet, then they’d have to get the fonts from somewhere. We couldn’t possibly ship the right fonts by default, because there are so many fonts and thus so many things to choose from.

Not sure how you missed it, but maybe it wasn’t as easy to find back then. Nowadays, it’s really easy to set up.

I think you misunderstood. I meant if I set a particular font from the template, that was used over the one I selected from settings (which is equivalent to preferences).

I mean open-source ones of course.

I think the popular ones help. I have had a lot of issues with rendering Urdu correctly and you might remember someone recently having their Arabic slanted like Nastaliq because of a font issue. A lot of people in the JP learning community face similar issues where their device mixes up ZH and JP characters. I also had problems with getting CJK characters from vietnam to work.

Also, FWIW Obsidian does it too. (Obsidian is kind of in the same productivity + education app sphere that Anki is in and I only hear about the app from other Anki users).

Either that, or we’re talking about two separate things. I’m confused now.


Regarding users fonts issues: I still don't think that justifies having the fonts preinstalled for every user. That should be the job of the OS, not an individual program. Though if it was an opt-in, like with addons, then I'd not be against this.

I mean you go to the settings and it’ll set a default font for everything in the app. But if you specify a certain font in your template that is used instead of the default.

Yeah, you should be able to not change anything. I don’t think the pre-installed part is the most important part of this suggestion though. It’s Anki having different fonts in different platforms (and not using ariel everywhere).

Wait a second.

  1. Are you proposing that the user has a setting to change the font of the UI of Anki?
  2. Or are you proposing that the user has a setting to change the font of the cards without having to use css?

Because even #1 is already possible, though not perfectly everywhere:

Source?

1 Like

I don’t quite understand what is being suggested here, but I thought this use case might be relevant. It’s niche, but it’s real.
Some years ago I had a deck to learn hanzi. In order to avoid ‘overfitting’, i.e. learning to recognize the characters of one specific font only to fail to recognize them when I find them in a different font ‘in the wild,’ I had four different ‘forward cards’ generated per note, each with a different font. I’ve also used the same principle to learn (different fonts of) blackletter.

This one. But yes, AnkiDroid’s setting also changed the interface font.

It’s somewhere there in GitHub but isn’t being worked on actively.

Ah, sorry. I’m misremembering. One of the maintainers did agree to reinstating the feature but there seems no open issue. Another maintainer closed them citing feature requests should not be in GH. So, “AnkiDroid will have it in the future” argument doesn’t work.

In any case, I really liked that feature and it allowed me to set a different font for my cards without having to do anything in the templates.