Last active
May 5, 2016 08:32
-
-
Save kopiro/01610bf5fa6d83c9f951 to your computer and use it in GitHub Desktop.
Typekit fonts hack
This file contains hidden or 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
| #!/usr/bin/php | |
| <?php | |
| define('TTF_DIR', $_SERVER['HOME'] . "/Library/Application Support/Adobe/CoreSync/plugins/livetype/.r"); | |
| define('XML_FILE', $_SERVER['HOME'] . "/Library/Application Support/Adobe/CoreSync/plugins/livetype/.c/entitlements.xml"); | |
| define('DST_DIR', $_SERVER['HOME'] . "/TypeKitFonts"); | |
| $map = []; | |
| $xml = new SimpleXmlElement(XML_FILE, LIBXML_COMPACT, true); | |
| foreach ($xml->fonts->font as $font) { | |
| $map[] = [ | |
| 'name' => strval($font->properties->fullName), | |
| 'infile' => strval(TTF_DIR . '/.' . $font->id . '.otf'), | |
| 'outfile' => strval(DST_DIR . '/' . $font->properties->familyName . '/' . $font->properties->fullName . '.otf') | |
| ]; | |
| } | |
| foreach ($map as $font) { | |
| @mkdir(dirname($font['outfile']), 0777, true); | |
| if (!file_exists($font['outfile'])) { | |
| echo "Copying " . $font['name'] . PHP_EOL; | |
| copy($font['infile'], $font['outfile']); | |
| } else { | |
| echo "Already copied " . $font['name'] . PHP_EOL; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment