It seems fonts are not included in exported in Anki deck?

I have this css in styling of card template but deck download from shared deck does not contain the icon files same for Anki desktop also.


@font-face {
  font-family: "Material Icons";
  font-style: normal;
  font-weight: 300;
  src: url(MaterialIcons-Regular.eot);
  /* For IE6-8 */
  src: local("Material Icons"), local("MaterialIcons-Regular"),
    url(_MaterialIcons-Regular.woff2) format("woff2"),
    url(_MaterialIcons-Regular.woff) format("woff"),
    url(_MaterialIcons-Regular.ttf) format("truetype")
}

Do you have all of those files included in your collection.media folder? Anki will only recognize and include (in an export) the ones that start with an underscore. Field Replacements - Anki Manual

It is in collection.media folder, but somehow not exporting.

I might be missing something obvious and/or noticing something irrelevant – but it looks like you’ve got at least 4 font files named there. Are all 4 of them in collection.media? Do all 4 of them have leading underscores (because they don’t in your CSS)?

This is a bug in the regex used to match underscored filenames in CSS: anki/rslib/src/text.rs at 39e293b27d36318e00131fd10144755eec8d1922 · ankitects/anki · GitHub

Demo: regex101: build, test, and debug regex

Maybe you can work around it by adding a newline before format()? Not sure whether that will still be recognized by the web engine.

2 Likes

Thanks