You are here

function google_fonts_api_preprocess_page in @font-your-face 6

Same name and namespace in other branches
  1. 6.2 modules/google_fonts_api/google_fonts_api.module \google_fonts_api_preprocess_page()
  2. 7 modules/google_fonts_api/google_fonts_api.module \google_fonts_api_preprocess_page()

Implements template_preprocess_page().

File

modules/google_fonts_api/google_fonts_api.module, line 50

Code

function google_fonts_api_preprocess_page(&$vars) {
  if (!empty($vars['fontyourface'])) {
    $paths = array();
    $fonts = google_fonts_api_list();
    foreach ($vars['fontyourface'] as $used_font) {
      if ($used_font->provider == 'google_fonts_api') {
        $paths[] = $fonts[$used_font->group_name]['fonts'][$used_font->name]['path'];
      }

      // if
    }

    // foreach
    if (count($paths) > 0) {
      $base = 'http://fonts.googleapis.com/css?family=';
      if ($_SERVER['HTTPS'] == 'on') {
        $base = 'https://fonts.googleapis.com/css?family=';
      }

      // if
      fontyourface_add_css_in_preprocess($vars, $base . implode('|', $paths), TRUE);
    }

    // if
  }

  // if
}