You are here

function typekit_api_list in @font-your-face 6

Provides a list of fonts for @font-your-face.

3 calls to typekit_api_list()
typekit_api_fontyourface_css in modules/typekit_api/typekit_api.module
Implements hook_fontyourface_css().
typekit_api_fontyourface_info in modules/typekit_api/typekit_api.module
Implements hook_fontyourface_info().
typekit_api_preprocess_page in modules/typekit_api/typekit_api.module
Implements template_preprocess_page().

File

modules/typekit_api/typekit_api.module, line 182

Code

function typekit_api_list($show_error = TRUE) {
  $fonts = array();
  $results = db_query('SELECT * FROM {typekit_api_variant}');
  while ($result = db_fetch_object($results)) {
    list($family, $variant) = explode(':', $result->typekit_id);
    if (!isset($fonts[$result->family])) {
      $fonts[$result->family] = array(
        'path' => urlencode($family),
        'fonts' => array(),
      );
    }

    // if
    $fonts[$result->family]['fonts'][$result->name] = array(
      'name' => $result->name,
      'path' => urlencode($variant),
      'css_name' => $result->css_name,
      'style' => $result->style,
      'variant' => $result->variant,
      'weight' => $result->weight,
      'foundry' => $result->foundry,
      'kit' => $result->kit,
    );
  }

  // while
  if (count($fonts) == 0 && $show_error) {
    drupal_set_message(t('No Typekit fonts have been imported yet. !importlink or wait until the next cron run. Note: make sure your Typekit kits are setup to use on this domain and include whatever fonts you would like to use.', array(
      '!importlink' => l(t('Import now'), 'admin/build/themes/fontyourface/typekit/import', array(
        'query' => drupal_get_destination(),
      )),
    )));
  }

  // if
  return $fonts;
}