Skip to content

Instantly share code, notes, and snippets.

@danyalette
Last active June 8, 2016 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danyalette/73af7f82548e668b2b2d698558c531f5 to your computer and use it in GitHub Desktop.
Save danyalette/73af7f82548e668b2b2d698558c531f5 to your computer and use it in GitHub Desktop.
make svg files from a fontello font's generated config file (for custom icons only)
<?php
$string = file_get_contents("config.json");
$json = json_decode($string, true);
$glyphs = $json[glyphs];
// make directory to hold resultant files
if (!file_exists('svg')) {
mkdir('svg', 0755, true);
}
foreach ($glyphs as $glyph) {
$name = $glyph['css'];
$string = iconString($glyph["svg"]["path"]);
file_put_contents("svg/{$name}.svg", $string);
}
function iconString($path){
return '<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg width="1000" height="1000" viewBox="0 0 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <path d="' . $path . '"></path></svg>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment