themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 328 forks source link

Backup font family and subsets #1789

Closed anthonyryanrusso closed 6 years ago

anthonyryanrusso commented 6 years ago

I've tried to search previous queries about these items but I can't find anything in your documentation about how to use a backup font family and subsets. Is there a way to provide the user a dropdown for these options?

Backup font family e.g. http://nimb.ws/U9wnlu

Font subset e.g. http://nimb.ws/BeiRJ3

aristath commented 6 years ago

These used to be part of the typography field but have been deprecated to simplify the options for users without actually taking away anything. :)

font-backup:

The info we have on the json file contains something like this for every font:

"ABeeZee": {
  "family": "ABeeZee",
  "category": "sans-serif",
  "variants":["italic","regular"]
}

So we automatically add the backup fonts in the generated CSS according to the "category" defined in google-fonts. You can see the font-families we use here: https://github.com/aristath/kirki/blob/c799637fba5f3f2357aa4f980d86c8905a6cad53/modules/webfonts/class-kirki-fonts.php#L105-L114 and if you want there's a kirki_fonts_backup_fonts filter in there that you can change.

font-subset

Since we switched to loading the googlefonts asyncronously, the fonts are no longer render-blocking and they can be loaded separately. So, we load all subsets. This way font-loading doesn't affect the page-speed, and all languages still work perfectly fine without any user interaction.

anthonyryanrusso commented 6 years ago

Ok great, didn't know that!