Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active May 5, 2016 08:32
Show Gist options
  • Select an option

  • Save kopiro/01610bf5fa6d83c9f951 to your computer and use it in GitHub Desktop.

Select an option

Save kopiro/01610bf5fa6d83c9f951 to your computer and use it in GitHub Desktop.
Typekit fonts hack
#!/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