You are here

function edge_fonts_preprocess_html in @font-your-face 7.2

Implements template_preprocess_html().

File

modules/edge_fonts/edge_fonts.module, line 57
Edge Fonts module main file.

Code

function edge_fonts_preprocess_html(&$vars) {
  if (!empty($vars['fontyourface'])) {
    $fonts = array();
    foreach ($vars['fontyourface'] as $active_font) {
      if ($active_font->provider == 'edge_fonts') {
        $metadata = unserialize($active_font->metadata);
        $fonts[$active_font->css_family][] = $metadata['variant'];
      }
    }
    if (count($fonts) > 0) {
      if (variable_get('edge_fonts_base', 'naked') == 'naked') {
        $base = '//use.edgefonts.net/';
      }
      elseif (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
        $base = 'https://use.edgefonts.net/';
      }
      else {
        $base = 'http://use.edgefonts.net/';
      }
      $families = array();
      $all_subsets = variable_get('edge_fonts_subsets', 'default') == 'all' ? ':all' : '';
      foreach ($fonts as $family => $variants) {
        $families[] = $family . ':' . implode(',', $variants) . $all_subsets;
      }
      $js = $base . implode(';', $families) . '.js';
      drupal_add_js($js, array(
        'type' => 'external',
      ));
    }
  }
}