mzdani / yii2-webfont-loader
Yii2 Web Font Loader Wrapper
Installs: 89
Dependents: 1
Suggesters: 0
Security: 0
Type:yii2-extension
pkg:composer/mzdani/yii2-webfont-loader
Requires
- yiisoft/yii2: ~2.0.6
This package is auto-updated.
Last update: 2025-10-29 02:08:57 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist "mzdani/yii2-webfont-loader" "dev-master"
or add
"mzdani/yii2-webfont-loader": "dev-master"
to the require section of your composer.json file.
Usage
Below is some example how to use the wrapper.
#!php
<?php
use \mdscomp\WebFontLoader;
WebFontLoader::widget([
	'classes'  => false,
	'event'    => false,
	'timeout'  => 2000,
	'context'  => "frames['my-child']",
	'text'     => 'abcdefghijklmnopqrstuvwxyz!',
	'callback' => [
		'loading'      => 'function(){}',
		'active'       => 'function(){}',
		'inactive'     => 'function(){}',
		'fontloading'  => 'function(familyName, fvd) {}',
		'fontactive'   => 'function(familyName, fvd) {console.log(\'font name\'+familyName);}',
		'fontinactive' => 'function(familyName, fvd) {}',
	],
	'CssFontName' => 'Roboto Condensed',
	'type'        => 'google',
	'families'    => ['Roboto+Condensed:400,700,300:latin'],
]);
WebFontLoader::widget([
	'CssFontName' => 'Roboto Condensed',
	'type'        => 'typekit',
	'families'    => 'xxxx',
]);
WebFontLoader::widget([
	'CssFontName' => 'Roboto Condensed',
	'type'        => 'fontdeck',
	'families'    => 'xxxx',
]);
WebFontLoader::widget([
	'CssFontName' => 'Roboto Condensed',
	'type'        => 'monotype',
	'families'    => [
		'id'  => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
		'ver' => 12345
	],
]);
?>
You must use `CssFontNamebecause the script automatically create<code>`</code> to call the font. I use it so I can dynamically change font without editing css file.</p>