php google fonts downloader with local css creation
- 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
- 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
- ->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")
->download();
returns array of all downloaded fonts
accepts callback function which is passed information on each font individually
- 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)