smtws / google-font-downloader
php google fonts downloader with local css creation
1.0.0
2020-01-17 13:11 UTC
Requires
- php: ^7.1
- psr/log: ^1.0
Suggests
- monolog/monolog: Allows more advanced logging of the application flow
This package is auto-updated.
Last update: 2024-11-22 22:09:28 UTC
README
php google fonts downloader with local css creation
Configuration via 3 options
- set Configuration in config.json and just call ->setConfig();
- set configuration via ->setConfig([array of configuration key value pairs]);
- set configuration via ->setConfig($key,$value);
combinations are possible
configurables:
- output: directory where fonts are downloaded to (each font family will have its own subdirectory) defaults to ./
- formats: optional array of font formats to be downloaded, defaults to all valid values. valid: eot,woff,woff2,svg,ttf
- onRecoverableError: how to handle recoverable errors. valid: stop(default), recover
add Fonts to Download list:
- ->addFont(string $fontFamily,string $fontStyle, array $fontWeights);
or
- ->addFontByUrl(string $urlOfFont);
(e.g. "https://fonts.google.com/?selection.family=Gelasio:500i,700|Open+Sans|Roboto" or "https://fonts.googleapis.com/css?family=Gelasio:500i,700|Open+Sans|Roboto&display=swap")
run:
->download();
returns array of all downloaded fonts
accepts callback function which is passed information on each font individually
more:
- PSR3 compatible loggers can be used
->setLogger(new \PSRCompatibleLogger());
- run ->createFamilyCssFiles()
on unrecoverable errors to create Font Family CSS files that were successfully downloaded before the error occured (see example.php)