You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fonts are a bit of an arse to do cross-browser, cross-device, so if you want complete control and consistency use @font-face and save your .ttf font files to Anki's collection.media folder. Loading speed on iOS/Android may be an issue, so probably two custom fonts max.
You'll find variables/typography.less, partials/headings.less and themes/cards/... css files are the places to go to make your edits.
Font calculations: Verdana is now our base font, but it's a bit too big by default. The global font-size: 1rem; is inherited by, for example, headers so making the font smaller globally will fuck up everything else. For now I'm targeting just the card notes.1
⚠️ Changing the default --font-sizerem screws everything else up. Increases size of all fonts, so be careful. Also, 1rem should allow user-edited font-size options in the browser.
Does changing rem on an element cascade? (like changing p affects <code> even if that tag has it's own rem declared? — It's safe to change elements with rem.
Page speed time in iOS / Android apps? — Anki's loading speed seems fine so far.
Monospace (ui-monospace) fails on Anki (but works in Safari). Manually writing 'San Francisco Mono' or 'SF Mono' is unpredictable in Safari and Anki. System font with system-ui seems to work on both.3
It's a subtle difference (I actually prefer SF Mono), but a good starting point for custom themes. You can see the Lhas a straight foot in SF Mono, but curve in DejaVu.
I feel the Print First CSS system-ui font stack is pretty good, but allowing custom fonts is a nice-to-have (and could help with code readability). However, after playing around with system-ui I'm now confused about the best route!2
Child themes — inheriting from print-first-css (basic font stack)
See the steps in the Anki documentation to add a custom font. The docs say to name your font myfont but on desktop I've named it the real font name and seems to work. Add the font to the collection.media folder.
Naming the font properly
On Anki desktop, using the proper font-family: 'Font Family Name'; seems to work. However, here only the second image will work — use the font name only ('DejaVu Sans') and use font-weight and font-style to specify the type of font (bold, italic, whatever).
⏳Card loading speed
You can use a hosted <link ...> tag — Anki doesn't expose the <header>, so use src: url(...) to load custom fonts from your collection.media folder.
There seems to be a potential issue with page load speed when using a custom font on Anki. I also can't find any useful information on using a URL for an @font-face with Anki.
Footnotes
This is where things get tricky as both font-size and line-height is dependent on the font type, so if it's a bigger font by default, that's potentially going to fuck up all our hard work with the baseline. Also, it's a bit uncertain where to put those font-size changes and there's some who say that you should use global utility classes to do so (like Tailwind). ↩
I'm like 70% sure. It might just fallback to sans-serif. See below. ↩↩2
Annoying quirks with Anki and Safari:'San Francisco Pro', or 'SF Pro' aren't available on the Font Book app but they are available as a system default. In Safari, system-ui seems to pick 'SF Pro' as it's default, as does ui-monospace with 'SF Pro Mono' — ui-monospace has poor support with Anki and browsers! Manually typing in the font-family (using the name of the San Francisco font) doesn't seem to work on Safari anymore, nor with Anki (I think my previous font stack was falling back to sans-serif. monospace weirdness: selects 'Courier' on Safari and 'Menlo' on Anki 🤦♂️🤬 ... I "think". ↩
The text was updated successfully, but these errors were encountered:
TL;DR
Fonts are a bit of an arse to do cross-browser, cross-device, so if you want complete control and consistency use
@font-face
and save your.ttf
font files to Anki'scollection.media
folder. Loading speed on iOS/Android may be an issue, so probably two custom fonts max.You'll find
variables/typography.less
,partials/headings.less
andthemes/cards/...
css files are the places to go to make your edits.Good monospaced fonts
Have already checked over these ...
system-ui
will use San Francisco on a Mac2ui-monospace
has poor support in browsers.--font-size
rem
screws everything else up. Increases size of all fonts, so be careful. Also,1rem
should allow user-editedfont-size
options in the browser.--font-size
withrem
a bad idea? (this article sets up a percentage)Does changing— It's safe to change elements withrem
on an element cascade? (like changingp
affects<code>
even if that tag has it's ownrem
declared?rem
.Page speed time in iOS / Android apps?— Anki's loading speed seems fine so far.Does the release deck import the custom font?Edit thetypography.less
andheadings.less
; orthemes/...
files?@font-face
fonts? (seems to work on desktop)Using default
--system
font stacksI feel the Print First CSS
system-ui
font stack is pretty good, but allowing custom fonts is a nice-to-have (and could help with code readability). However, after playing around withsystem-ui
I'm now confused about the best route!2print-first-css
(basic font stack)Verdana looks a bit shit at default
--font-size
🤔 Anki custom font quirks
Naming the font properly
⏳Card loading speed
There seems to be a potential issue with page load speed when using a custom font on Anki. I also can't find any useful information on using a URL for an
@font-face
with Anki.Footnotes
This is where things get tricky as both
font-size
andline-height
is dependent on the font type, so if it's a bigger font by default, that's potentially going to fuck up all our hard work with the baseline. Also, it's a bit uncertain where to put thosefont-size
changes and there's some who say that you should use global utility classes to do so (like Tailwind). ↩I'm like 70% sure. It might just fallback to
sans-serif
. See below. ↩ ↩2Annoying quirks with Anki and Safari:
'San Francisco Pro'
, or'SF Pro'
aren't available on the Font Book app but they are available as a system default. In Safari,system-ui
seems to pick'SF Pro'
as it's default, as doesui-monospace
with'SF Pro Mono'
—ui-monospace
has poor support with Anki and browsers! Manually typing in thefont-family
(using the name of the San Francisco font) doesn't seem to work on Safari anymore, nor with Anki (I think my previous font stack was falling back tosans-serif
.monospace
weirdness: selects'Courier'
on Safari and'Menlo'
on Anki 🤦♂️🤬 ... I "think". ↩The text was updated successfully, but these errors were encountered: