You are here

function fontyourface_preprocess_page in @font-your-face 7

Same name and namespace in other branches
  1. 6.2 fontyourface.module \fontyourface_preprocess_page()
  2. 6 fontyourface.module \fontyourface_preprocess_page()

Implements template_preprocess_page().

File

./fontyourface.module, line 512

Code

function fontyourface_preprocess_page(&$vars) {
  $fonts = fontyourface_font_registry();
  $destination = file_build_uri('fontyourface/font.css');
  $css = '';
  $destination_directory = dirname($destination);
  if (file_prepare_directory($destination_directory, FILE_CREATE_DIRECTORY)) {
    $enabled_fonts = fontyourface_get_fonts();
    foreach ($enabled_fonts as $font) {
      $font_css = fontyourface_font_css($font);
      if ($font_css != '' && $font->css_selector != '') {
        $css .= $font->css_selector . ' { ' . $font_css . ' }' . "\n";
      }

      // if
      $fonts[] = $font;
    }

    // foreach
    file_unmanaged_save_data($css, $destination, FILE_EXISTS_REPLACE);
  }

  // if
  if ($css != '') {
    fontyourface_add_css_in_preprocess($vars, 'fontyourface/font.css');
  }

  // if
  $vars['fontyourface'] = $fonts;
}