composer require zdenekzahor/webfontloader
extensions:
webFontLoader: ZdenekZahor\WebFontLoader\DI\WebFontLoaderExtension
webFontLoader:
cookieName: wfont
families:
-
name: Play
weights:
- 400
- 700
subsets:
- latin
- latin-ext
use ZdenekZahor\WebFontLoader\IWebFontLoaderFactory;
use ZdenekZahor\WebFontLoader\WebFontLoader;
/**
* @var IWebFontLoaderFactory
* @inject
*/
public $webFontLoaderFactory;
protected function createComponentWebFontLoader(): WebFontLoader
{
return $this->webFontLoaderFactory->create();
}
<!DOCTYPE html>
<html class="{control webFontLoader:htmlClass}">
<head>
{control webFontLoader:head}
</head>
html {
font-family: sans-serif;
}
html.wf-active {
font-family: 'Play', sans-serif;
}