You are here

function fontsquirrel_fontyourface_import in @font-your-face 6.2

Same name and namespace in other branches
  1. 7.2 modules/fontsquirrel/fontsquirrel.module \fontsquirrel_fontyourface_import()
  2. 7 modules/fontsquirrel/fontsquirrel.module \fontsquirrel_fontyourface_import()

Implements hook_fontyourface_import().

File

modules/fontsquirrel/fontsquirrel.module, line 205

Code

function fontsquirrel_fontyourface_import() {
  $api_result = drupal_http_request('http://www.fontsquirrel.com/api/fontlist/all');
  if ($api_result->code == '200') {
    $decoded = json_decode($api_result->data);
    foreach ($decoded as $font_import) {
      $metadata = array(
        'id' => $font_import->id,
        'path' => $font_import->family_urlname,
        'font_filename' => $font_import->font_filename,
      );
      $font = new StdClass();
      $font->name = $font_import->family_name;
      $font->url = 'http://www.fontsquirrel.com/fonts/' . $font_import->family_urlname;
      $font->provider = 'fontsquirrel';
      $font->foundry = $font_import->foundry_name;
      $font->foundry_url = 'http://www.fontsquirrel.com/foundry/' . $font_import->foundry_urlname;
      $font->license = 'See Font Squirrel license page';
      $font->license_url = 'http://www.fontsquirrel.com/fonts/' . $font_import->family_urlname . '#eula';
      $font->tags = array(
        $font_import->classification,
      );
      $font->metadata = serialize($metadata);
      fontyourface_save_font($font);
    }

    // foreach
  }

  // if
}