Last active
June 8, 2016 21:34
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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